// Boost.Range library // // Copyright Robin Eckert 2015. Use, modification and distribution is // subject to 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) // // // For more information, see http://www.boost.org/libs/range/ // #include #define BOOST_TEST_MAIN #include #include #include #if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) namespace boost { BOOST_AUTO_TEST_CASE(test_mutable) { int one = 1; int two = 2; int three = 3; std::vector> input_values{one, two, three}; const std::vector expected{&one, &two, &three}; std::vector actual; for (auto&& value : input_values | adaptors::ref_unwrapped) { actual.push_back(&value); } BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end()); } BOOST_AUTO_TEST_CASE(test_const_range) { int one = 1; int two = 2; int three = 3; const std::vector> input_values{one, two, three}; const std::vector expected{&one, &two, &three}; std::vector actual; for (auto&& value : input_values | adaptors::ref_unwrapped) { actual.push_back(&value); } BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end()); } BOOST_AUTO_TEST_CASE(test_const_reference) { const int one = 1; const int two = 2; const int three = 3; const std::vector> input_values{one, two, three}; const std::vector expected{&one, &two, &three}; std::vector actual; for (auto&& value : input_values | adaptors::ref_unwrapped) { actual.push_back(&value); } BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end()); } } #else BOOST_AUTO_TEST_CASE(empty) { // C++11 only } #endif