1// Boost.Range library
2//
3// Copyright Robin Eckert 2015. Use, modification and distribution is
4// subject to the Boost Software License, Version 1.0. (See
5// accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8//
9// For more information, see http://www.boost.org/libs/range/
10//
11//[ref_unwrapped_example
12#include <boost/range/adaptor/ref_unwrapped.hpp>
13#include <iostream>
14#include <vector>
15
16struct example
17{
18 int value;
19};
20
21int main(int argc, const char* argv[])
22{
23//<-
24#if !defined(BOOST_NO_CXX11_DECLTYPE) \
25 && !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) \
26 && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
27 && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
28//->
29 using boost::adaptors::ref_unwrapped;
30
31 example one{.value: 1};
32 example two{.value: 2};
33 example three{.value: 3};
34
35 std::vector<std::reference_wrapper<example> > input{one, two, three};
36
37 for (auto&& entry : input | ref_unwrapped)
38 {
39 std::cout << entry.value;
40 }
41
42 return 0;
43//<-
44#endif
45//->
46}
47//]
48

source code of boost/libs/range/test/adaptor_test/ref_unwrapped_example.cpp