From 5bc9e47688e19d282594b6b8fe2aec5d8c74552f Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Wed, 12 Jul 2017 20:14:48 +0300 Subject: [PATCH] Changed iterator_category nested type detection to work with MSVC and different versions of gcc. --- include/boost/next_prior.hpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/include/boost/next_prior.hpp b/include/boost/next_prior.hpp index 986c9d9..58da590 100644 --- a/include/boost/next_prior.hpp +++ b/include/boost/next_prior.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -42,24 +43,20 @@ namespace next_prior_detail { // Still, this is a good heuristic in practice, and we can't do anything better anyway. // Since C++17 we can test for iterator_traits::iterator_category presence instead as it is // required to be only present for iterators. -template< typename T > +template< typename T, typename Void = void > struct is_iterator { -private: - typedef char yes_type; - typedef char (&no_type)[2]; - - template< typename U > - static yes_type check_iterator_category(typename U::iterator_category*); - template< typename U > - static no_type check_iterator_category(...); - -public: - static BOOST_CONSTEXPR_OR_CONST bool value = sizeof(is_iterator< T >::BOOST_NESTED_TEMPLATE check_iterator_category< T >(0)) == sizeof(yes_type); + static BOOST_CONSTEXPR_OR_CONST bool value = false; }; template< typename T > -struct is_iterator< T* > +struct is_iterator< T, typename enable_if_has_type< typename T::iterator_category >::type > +{ + static BOOST_CONSTEXPR_OR_CONST bool value = true; +}; + +template< typename T > +struct is_iterator< T*, void > { static BOOST_CONSTEXPR_OR_CONST bool value = true; };