diff --git a/iterator_adaptor_test.cpp b/iterator_adaptor_test.cpp index 67058f3..cb22d87 100644 --- a/iterator_adaptor_test.cpp +++ b/iterator_adaptor_test.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -105,7 +106,7 @@ main() const int N = sizeof(array)/sizeof(dummyT); // sanity check, if this doesn't pass the test is buggy - boost::random_access_iterator_test(array,N,array); + boost::random_access_iterator_test(array, N, array); // Check that the policy concept checks and the default policy // implementation match up. @@ -117,6 +118,41 @@ main() int*, int&> > >(); + // Test the named parameters + { + // Test computation of defaults + typedef boost::iterator_adaptor > Iter1; + BOOST_STATIC_ASSERT((boost::is_same::value_type, int>::value)); + BOOST_STATIC_ASSERT((boost::is_same::reference, int&>::value)); + BOOST_STATIC_ASSERT((boost::is_same::pointer, int*>::value)); + BOOST_STATIC_ASSERT((boost::is_same::difference_type, std::ptrdiff_t>::value)); + BOOST_STATIC_ASSERT((boost::is_same::iterator_category, std::random_access_iterator_tag>::value)); + } + { + // Test computation of default when the Value is const + typedef boost::iterator_adaptor > Iter1; + BOOST_STATIC_ASSERT((boost::is_same::value_type, int>::value)); + BOOST_STATIC_ASSERT((boost::is_same::reference, const int&>::value)); + BOOST_STATIC_ASSERT((boost::is_same::pointer, const int*>::value)); + } + { + // Test with no defaults + typedef boost::iterator_adaptor, + boost::pointer_is, + boost::value_type_is, + boost::iterator_category_is, + boost::difference_type_is + > Iter1; + BOOST_STATIC_ASSERT((boost::is_same::value_type, char>::value)); + BOOST_STATIC_ASSERT((boost::is_same::reference, long>::value)); + BOOST_STATIC_ASSERT((boost::is_same::pointer, float>::value)); + BOOST_STATIC_ASSERT((boost::is_same::difference_type, int>::value)); + BOOST_STATIC_ASSERT((boost::is_same::iterator_category, std::input_iterator_tag>::value)); + } + // Test the iterator_adaptor { boost::iterator_adaptor i(array); @@ -307,12 +343,12 @@ main() #else typedef boost::iterator_adaptor, boost::default_iterator_policies, - boost::iterator_traits_generator - ::value_type - ::reference - ::pointer - ::iterator_category - ::difference_type > adaptor_type; + boost::reference_is, + boost::pointer_is , + boost::iterator_category_is, + boost::value_type_is, + boost::difference_type_is + > adaptor_type; #endif adaptor_type i(forward_iter); int zero = 0;