From 0e9a9e613bcd16ec6e28faf86407f2cab3f0d4fa Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Sep 2014 15:37:45 +0200 Subject: [PATCH 1/2] Rely on the 'typename' keyword from the compiler. Remove trailing whitespace from modified lines. git grep -l BOOST_STRING_TYPENAME | xargs sed -i 's|BOOST_STRING_TYPENAME *$|typename|' git grep -l BOOST_STRING_TYPENAME | xargs sed -i 's|BOOST_STRING_TYPENAME \(.*\) +$|typename \1|' git grep -l BOOST_STRING_TYPENAME | xargs sed -i 's|BOOST_STRING_TYPENAME|typename|' Remove include of header from Boost.Algorithm library providing the define. --- .../boost/range/detail/collection_traits.hpp | 43 +++++++++-------- .../range/detail/collection_traits_detail.hpp | 47 +++++++++---------- 2 files changed, 44 insertions(+), 46 deletions(-) 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..c9c3fb3 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 @@ -41,16 +40,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 > @@ -135,12 +134,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 +220,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 +248,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 +275,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 +303,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 +322,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 +400,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 +412,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 From 8bb3a85f68797710a591c4b29646f2ce89015fe6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Sep 2014 15:37:21 +0200 Subject: [PATCH 2/2] Use local sfinae typedefs for yes_type and no_type. Remove dependency on Boost.Algorithm library. --- include/boost/range/detail/collection_traits_detail.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/range/detail/collection_traits_detail.hpp b/include/boost/range/detail/collection_traits_detail.hpp index c9c3fb3..1545997 100644 --- a/include/boost/range/detail/collection_traits_detail.hpp +++ b/include/boost/range/detail/collection_traits_detail.hpp @@ -23,7 +23,6 @@ #include #include #include -#include // Container traits implementation --------------------------------------------------------- @@ -115,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* );