// Based on the Boost.Cobalt documentation examples.
// Copyright (c) 2023 Klemens D. Morgenstern
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/cobalt/main.hpp>
#include <boost/cobalt/promise.hpp>
#include <iostream>

namespace cobalt = boost::cobalt;

cobalt::promise<int> add(int a, int b)
{
  co_return a + b;
}

cobalt::main co_main(int, char *[])
{
  const int result = co_await add(19, 23);
  std::cout << "19 + 23 = " << result << std::endl;
  co_return result == 42 ? 0 : 1;
}
