1// Copyright 2021 Peter Dimov.
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#include <boost/system/result.hpp>
6#include <boost/core/lightweight_test.hpp>
7#include <vector>
8
9using namespace boost::system;
10
11result<std::vector<int>> f()
12{
13 return std::vector<int>{ 1, 2, 3 };
14}
15
16int main()
17{
18 {
19 int s = 0;
20
21 for( int x: f().value() )
22 {
23 s += x;
24 }
25
26 BOOST_TEST_EQ( s, 6 );
27 }
28
29 return boost::report_errors();
30}
31

source code of boost/libs/system/test/result_range_for.cpp