// Boost.Range library // // Copyright Neil Groves 2014. 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 #include #include #include #include #include namespace { struct identity { typedef int result_type; result_type operator()(int i) const { return i; } }; void sliced_and_transformed() { using namespace boost::adaptors; std::vector input; for (int i = 0; i < 10; ++i) input.push_back(i); std::vector out1; boost::push_back(out1, input | sliced(2, 8) | transformed(identity())); std::vector out2; boost::push_back(out2, input | transformed(identity()) | sliced(2, 8)); BOOST_CHECK_EQUAL_COLLECTIONS(out1.begin(), out1.end(), out2.begin(), out2.end()); } } // anonymous namespace boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range adaptors - sliced and transformed" ); test->add(BOOST_TEST_CASE(&sliced_and_transformed)); return test; }