Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Prev Up HomeNext

Coroutine TRY operation

As one cannot call statement return from within a Coroutine, the very first part of Outcome’s support for Coroutines is BOOST_OUTCOME_CO_TRYV(expr)/BOOST_OUTCOME_CO_TRY(expr) , which is literally the same as BOOST_OUTCOME_TRY() except that co_return is called to return early instead of return.

eager<result<std::string>> to_string(int x)
{
  if(x >= 0)
  {
    BOOST_OUTCOME_CO_TRY(convert(x));
  }
  co_return "out of range";
}

Last revised: April 07, 2020 at 10:22:38 +0100


Prev Up HomeNext