diff --git a/test/iterator_adaptor_test.cpp b/test/iterator_adaptor_test.cpp index 727f12b..6e71714 100644 --- a/test/iterator_adaptor_test.cpp +++ b/test/iterator_adaptor_test.cpp @@ -155,6 +155,19 @@ public: in_iterator(boost::input_iterator_archetype d) : super_t(d) { } }; +template +struct constant_iterator + : boost::iterator_adaptor< + constant_iterator + , Iter + , typename std::iterator_traits::value_type const + > +{ + constant_iterator() {} + constant_iterator(Iter it) + : constant_iterator::iterator_adaptor(it) {} +}; + int main() { @@ -194,7 +207,6 @@ main() typedef ptr_iterator Iter1; BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) @@ -202,6 +214,19 @@ main() BOOST_STATIC_ASSERT((boost::is_same::value)); #endif } + + { + // Test constant iterator idiom + typedef ptr_iterator BaseIter; + typedef constant_iterator Iter; + + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + } // Test the iterator_adaptor {