// Copyright (c) 2018 Emil Dotchevski // Copyright (c) 2018 Second Spectrum, Inc. // 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 #include #include "boost/core/lightweight_test.hpp" namespace leaf = boost::leaf; template struct info { int value; }; leaf::result f12() { return leaf::new_error( info<1>{1}, info<2>{2} ); } leaf::result f23() { return leaf::new_error( info<2>{2}, info<3>{3} ); } int main() { int r = leaf::handle_all( [ ]() -> leaf::result { leaf::result r1 = f12(); (void) r1; leaf::result r2 = f23(); return r2.error(); }, [ ]( info<1> ) { return 1; }, [ ]( info<2> const & x, info<3> const & y ) { BOOST_TEST(x.value==2); BOOST_TEST(y.value==3); return 2; }, [ ] { return 3; } ); BOOST_TEST(r==2); return boost::report_errors(); }