// 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 #include #include namespace boost_range_test { struct point { int x; int y; }; class shape { public: virtual ~shape() { } const std::vector& points() const { return m_points; } private: std::vector m_points; }; class rectangle : public shape { }; class circle : public shape { }; class container { typedef std::vector impl_t; }; } // namespace boost_range_test namespace boost { template struct range_mutable_iterator< T, typename boost::enable_if< boost::is_base_of< boost_range_test::shape, typename boost::remove_reference< typename boost::remove_cv::type >::type > >::type > { typedef std::vector::iterator type; }; template struct range_const_iterator< T, typename boost::enable_if< boost::is_base_of< boost_range_test::shape, typename boost::remove_reference< typename boost::remove_cv::type >::type > >::type > { typedef std::vector::const_iterator type; }; template<> struct range_mutable_iterator { typedef std::vector::iterator type; }; template<> struct range_const_iterator { typedef std::vector::const_iterator type; }; } namespace boost_range_test { template void test_iterator_impl() { BOOST_STATIC_ASSERT(( boost::is_same< std::vector::iterator, typename boost::range_iterator::type >::value)); BOOST_STATIC_ASSERT(( boost::is_same< std::vector::const_iterator, typename boost::range_iterator::type >::value)); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES BOOST_STATIC_ASSERT(( boost::is_same< std::vector::iterator, typename boost::range_iterator::type >::value)); #endif } void test_iterator() { test_iterator_impl(); test_iterator_impl(); test_iterator_impl(); test_iterator_impl(); } } // namespace boost_range_test boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { boost::unit_test::test_suite* test = BOOST_TEST_SUITE("Boost.Range range_iterator meta-function"); test->add(BOOST_TEST_CASE(&boost_range_test::test_iterator)); return test; }