2
0
mirror of https://github.com/boostorg/leaf.git synced 2026-02-01 08:32:14 +00:00
This commit is contained in:
Emil Dotchevski
2020-10-20 12:23:13 -07:00
parent c20262d1f8
commit 44eec77cf0
103 changed files with 15900 additions and 15900 deletions

View File

@@ -13,38 +13,38 @@ namespace leaf = boost::leaf;
template <int>
struct info
{
int value;
int value;
};
leaf::error_id g()
{
auto load = leaf::on_error( [](info<1> & x) {++x.value;} );
return leaf::new_error();
auto load = leaf::on_error( [](info<1> & x) {++x.value;} );
return leaf::new_error();
}
leaf::error_id f()
{
auto load = leaf::on_error( [](info<1> & x) {++x.value;}, [](info<2> & x) {++x.value;} );
return g();
auto load = leaf::on_error( [](info<1> & x) {++x.value;}, [](info<2> & x) {++x.value;} );
return g();
}
int main()
{
int r = leaf::try_handle_all(
[]() -> leaf::result<int>
{
return f();
},
[]( info<1> const & a, info<2> const & b )
{
BOOST_TEST_EQ(a.value, 2);
BOOST_TEST_EQ(b.value, 1);
return 1;
},
[]
{
return 2;
} );
BOOST_TEST_EQ(r, 1);
return boost::report_errors();
int r = leaf::try_handle_all(
[]() -> leaf::result<int>
{
return f();
},
[]( info<1> const & a, info<2> const & b )
{
BOOST_TEST_EQ(a.value, 2);
BOOST_TEST_EQ(b.value, 1);
return 1;
},
[]
{
return 2;
} );
BOOST_TEST_EQ(r, 1);
return boost::report_errors();
}