diff --git a/doc/reference/algorithms.qbk b/doc/reference/algorithms.qbk index ce4b140..8dcd848 100644 --- a/doc/reference/algorithms.qbk +++ b/doc/reference/algorithms.qbk @@ -63,7 +63,7 @@ std::vector vec = ...; boost::erase(vec, boost::unique(boost::sort(vec))); `` -Notice the use of `boost::return_found_end`. What if we wanted to erase all the duplicates except one of them? In old-fashined STL-programming we might write +Notice the use of `boost::return_found_end`. What if we wanted to erase all the duplicates except one of them? In old-fashioned STL-programming we might write `` // assume 'vec' is already sorted diff --git a/include/boost/range/detail/any_iterator.hpp b/include/boost/range/detail/any_iterator.hpp index ffc0aeb..044237c 100644 --- a/include/boost/range/detail/any_iterator.hpp +++ b/include/boost/range/detail/any_iterator.hpp @@ -114,7 +114,8 @@ namespace boost }; } // namespace range_detail - namespace iterators { + namespace iterators + { namespace detail { // Rationale: diff --git a/include/boost/range/detail/any_iterator_wrapper.hpp b/include/boost/range/detail/any_iterator_wrapper.hpp index bcd9b7f..c542d39 100644 --- a/include/boost/range/detail/any_iterator_wrapper.hpp +++ b/include/boost/range/detail/any_iterator_wrapper.hpp @@ -10,7 +10,7 @@ #ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED #define BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED -#include +#include #include #include #include diff --git a/include/boost/range/detail/collection_traits.hpp b/include/boost/range/detail/collection_traits.hpp index c50ca3e..823c0af 100644 --- a/include/boost/range/detail/collection_traits.hpp +++ b/include/boost/range/detail/collection_traits.hpp @@ -22,7 +22,6 @@ #ifndef BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP #define BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP -#include #include #include #include @@ -74,13 +73,13 @@ namespace boost { struct collection_traits { private: - typedef BOOST_STRING_TYPENAME ::boost::mpl::eval_if< + typedef typename ::boost::mpl::eval_if< ::boost::algorithm::detail::is_pair, detail::pair_container_traits_selector, - BOOST_STRING_TYPENAME ::boost::mpl::eval_if< + typename ::boost::mpl::eval_if< ::boost::is_array, detail::array_container_traits_selector, - BOOST_STRING_TYPENAME ::boost::mpl::eval_if< + typename ::boost::mpl::eval_if< ::boost::is_pointer, detail::pointer_container_traits_selector, detail::default_container_traits_selector @@ -91,22 +90,22 @@ namespace boost { //! Function type typedef container_helper_type function_type; //! Value type - typedef BOOST_STRING_TYPENAME + typedef typename container_helper_type::value_type value_type; //! Size type - typedef BOOST_STRING_TYPENAME + typedef typename container_helper_type::size_type size_type; //! Iterator type - typedef BOOST_STRING_TYPENAME + typedef typename container_helper_type::iterator iterator; //! Const iterator type - typedef BOOST_STRING_TYPENAME + typedef typename container_helper_type::const_iterator const_iterator; //! Result iterator type ( iterator of const_iterator, depending on the constness of the container ) - typedef BOOST_STRING_TYPENAME + typedef typename container_helper_type::result_iterator result_iterator; //! Difference type - typedef BOOST_STRING_TYPENAME + typedef typename container_helper_type::difference_type difference_type; }; // 'collection_traits' @@ -120,7 +119,7 @@ namespace boost { template< typename C > struct value_type_of { - typedef BOOST_STRING_TYPENAME collection_traits::value_type type; + typedef typename collection_traits::value_type type; }; //! Container difference trait @@ -130,7 +129,7 @@ namespace boost { template< typename C > struct difference_type_of { - typedef BOOST_STRING_TYPENAME collection_traits::difference_type type; + typedef typename collection_traits::difference_type type; }; //! Container iterator trait @@ -140,7 +139,7 @@ namespace boost { template< typename C > struct iterator_of { - typedef BOOST_STRING_TYPENAME collection_traits::iterator type; + typedef typename collection_traits::iterator type; }; //! Container const_iterator trait @@ -150,7 +149,7 @@ namespace boost { template< typename C > struct const_iterator_of { - typedef BOOST_STRING_TYPENAME collection_traits::const_iterator type; + typedef typename collection_traits::const_iterator type; }; @@ -162,7 +161,7 @@ namespace boost { template< typename C > struct result_iterator_of { - typedef BOOST_STRING_TYPENAME collection_traits::result_iterator type; + typedef typename collection_traits::result_iterator type; }; // collection_traits related functions -----------------------------------------// @@ -172,7 +171,7 @@ namespace boost { Get the size of the container. Uses collection_traits. */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::size_type + inline typename collection_traits::size_type size( const C& c ) { return collection_traits::function_type::size( c ); @@ -195,7 +194,7 @@ namespace boost { Get the begin iterator of the container. Uses collection_traits. */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::iterator + inline typename collection_traits::iterator begin( C& c ) { return collection_traits::function_type::begin( c ); @@ -206,7 +205,7 @@ namespace boost { \overload */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::const_iterator + inline typename collection_traits::const_iterator begin( const C& c ) { return collection_traits::function_type::begin( c ); @@ -217,7 +216,7 @@ namespace boost { Get the begin iterator of the container. Uses collection_traits. */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::iterator + inline typename collection_traits::iterator end( C& c ) { return collection_traits::function_type::end( c ); @@ -228,7 +227,7 @@ namespace boost { \overload */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::const_iterator + inline typename collection_traits::const_iterator end( const C& c ) { return collection_traits::function_type::end( c ); @@ -241,7 +240,7 @@ namespace boost { \overload */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::result_iterator + inline typename collection_traits::result_iterator begin( C& c ) { return collection_traits::function_type::begin( c ); @@ -252,7 +251,7 @@ namespace boost { \overload */ template< typename C > - inline BOOST_STRING_TYPENAME collection_traits::result_iterator + inline typename collection_traits::result_iterator end( C& c ) { return collection_traits::function_type::end( c ); diff --git a/include/boost/range/detail/collection_traits_detail.hpp b/include/boost/range/detail/collection_traits_detail.hpp index 1f2b77c..1545997 100644 --- a/include/boost/range/detail/collection_traits_detail.hpp +++ b/include/boost/range/detail/collection_traits_detail.hpp @@ -10,7 +10,6 @@ #ifndef BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP #define BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP -#include #include #include #include @@ -24,7 +23,6 @@ #include #include #include -#include // Container traits implementation --------------------------------------------------------- @@ -41,16 +39,16 @@ namespace boost { template< typename ContainerT > struct default_container_traits { - typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type; - typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator; - typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator; - typedef BOOST_STRING_TYPENAME + typedef typename ContainerT::value_type value_type; + typedef typename ContainerT::iterator iterator; + typedef typename ContainerT::const_iterator const_iterator; + typedef typename ::boost::mpl::if_< ::boost::is_const, const_iterator, iterator >::type result_iterator; - typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type; - typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type; + typedef typename ContainerT::difference_type difference_type; + typedef typename ContainerT::size_type size_type; // static operations template< typename C > @@ -116,7 +114,10 @@ namespace boost { }; // Pair container traits --------------------------------------------------------------------- - + + typedef double yes_type; + typedef char no_type; + // pair selector template< typename T, typename U > yes_type is_pair_impl( const std::pair* ); @@ -135,12 +136,12 @@ namespace boost { template< typename PairT > struct pair_container_traits { - typedef BOOST_STRING_TYPENAME PairT::first_type element_type; + typedef typename PairT::first_type element_type; - typedef BOOST_STRING_TYPENAME ::boost::detail:: + typedef typename ::boost::detail:: iterator_traits::value_type value_type; typedef std::size_t size_type; - typedef BOOST_STRING_TYPENAME ::boost::detail:: + typedef typename ::boost::detail:: iterator_traits::difference_type difference_type; typedef element_type iterator; @@ -221,7 +222,7 @@ namespace boost { template< typename TraitsT > struct array_length { - typedef BOOST_STRING_TYPENAME + typedef typename TraitsT::size_type size_type; BOOST_STATIC_CONSTANT( @@ -249,7 +250,7 @@ namespace boost { template< typename TraitsT > struct array_length { - typedef BOOST_STRING_TYPENAME + typedef typename TraitsT::size_type size_type; template< typename A > @@ -276,7 +277,7 @@ namespace boost { template< typename TraitsT > struct array_length { - typedef BOOST_STRING_TYPENAME + typedef typename TraitsT::size_type size_type; template< typename A > @@ -304,18 +305,18 @@ namespace boost { typedef array_traits traits_type; public: - typedef BOOST_STRING_TYPENAME + typedef typename traits_type::value_type value_type; - typedef BOOST_STRING_TYPENAME + typedef typename traits_type::iterator iterator; - typedef BOOST_STRING_TYPENAME + typedef typename traits_type::const_iterator const_iterator; - typedef BOOST_STRING_TYPENAME + typedef typename traits_type::size_type size_type; - typedef BOOST_STRING_TYPENAME + typedef typename traits_type::difference_type difference_type; - typedef BOOST_STRING_TYPENAME + typedef typename ::boost::mpl::if_< ::boost::is_const, const_iterator, iterator @@ -323,9 +324,9 @@ namespace boost { private: // resolve array size - typedef BOOST_STRING_TYPENAME + typedef typename ::boost::remove_cv::type char_type; - typedef BOOST_STRING_TYPENAME + typedef typename array_length_selector:: BOOST_NESTED_TEMPLATE array_length array_length_type; @@ -401,10 +402,10 @@ namespace boost { template struct pointer_container_traits { - typedef BOOST_STRING_TYPENAME + typedef typename ::boost::remove_pointer::type value_type; - typedef BOOST_STRING_TYPENAME + typedef typename ::boost::remove_cv::type char_type; typedef ::std::char_traits char_traits; @@ -413,7 +414,7 @@ namespace boost { typedef std::ptrdiff_t difference_type; typedef std::size_t size_type; - typedef BOOST_STRING_TYPENAME + typedef typename ::boost::mpl::if_< ::boost::is_const, const_iterator, iterator diff --git a/include/boost/range/detail/demote_iterator_traversal_tag.hpp b/include/boost/range/detail/demote_iterator_traversal_tag.hpp index 2127de9..6d65720 100644 --- a/include/boost/range/detail/demote_iterator_traversal_tag.hpp +++ b/include/boost/range/detail/demote_iterator_traversal_tag.hpp @@ -79,8 +79,8 @@ BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal template struct demote_iterator_traversal_tag : inner_demote_iterator_traversal_tag< - typename boost::detail::pure_traversal_tag< IteratorTraversalTag1 >::type, - typename boost::detail::pure_traversal_tag< IteratorTraversalTag2 >::type + typename boost::iterators::pure_traversal_tag< IteratorTraversalTag1 >::type, + typename boost::iterators::pure_traversal_tag< IteratorTraversalTag2 >::type > { }; diff --git a/include/boost/range/iterator_range_core.hpp b/include/boost/range/iterator_range_core.hpp index 8108947..2fbeb68 100644 --- a/include/boost/range/iterator_range_core.hpp +++ b/include/boost/range/iterator_range_core.hpp @@ -442,8 +442,8 @@ public: > base_type; template - struct is_compatible_range - : is_convertible< + struct is_compatible_range_ + : is_convertible< BOOST_DEDUCED_TYPENAME mpl::eval_if< has_range_iterator, range_iterator, @@ -454,6 +454,20 @@ public: { }; + template + struct is_compatible_range + : mpl::and_< + mpl::not_< + is_convertible< + Source, + BOOST_DEDUCED_TYPENAME base_type::iterator + > + >, + is_compatible_range_ + > + { + }; + protected: typedef iterator_range_detail::iterator_range_impl impl; diff --git a/meta/libraries.json b/meta/libraries.json new file mode 100644 index 0000000..9e2be20 --- /dev/null +++ b/meta/libraries.json @@ -0,0 +1,16 @@ +{ + "key": "range", + "name": "Range", + "authors": [ + "Niel Groves", + "Thorsten Ottosen" + ], + "description": "A new infrastructure for generic algorithms that builds on top of the new iterator concepts.", + "category": [ + "Algorithms" + ], + "maintainers": [ + "Neil Groves ", + "Nathan Ridge " + ] +} diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 168eb22..97c966a 100644 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -266,21 +266,18 @@ inline void test_advance() BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u); } -boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +struct ptr_iterator + : boost::iterator_adaptor { - boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + ptr_iterator() {} + ptr_iterator(int *p) : boost::iterator_adaptor(p) {} +private: + typedef void iterator; // To throw off the SFINAE mechanism in iterator_range +}; - test->add(BOOST_TEST_CASE(&check_iterator_range)); - test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); - test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); - test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); - test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); - test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); - test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); - test->add(BOOST_TEST_CASE(&iterator_range_test_detail::check_make_iterator_range_n)); - test->add(BOOST_TEST_CASE(&test_advance)); - - return test; +void test_sfinae() +{ + boost::iterator_range r(ptr_iterator(0), ptr_iterator(0)); } // @@ -313,3 +310,21 @@ void check_reference_type() test_iter_range(a_vec); test_iter_range(a_vec); } + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + + test->add(BOOST_TEST_CASE(&check_iterator_range)); + test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); + test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); + test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); + test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); + test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); + test->add(BOOST_TEST_CASE(&check_iterator_range_operator)); + test->add(BOOST_TEST_CASE(&iterator_range_test_detail::check_make_iterator_range_n)); + test->add(BOOST_TEST_CASE(&test_advance)); + + return test; +} +