From 2722fdcda359b5b084f4a014b24ca93086d86525 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 23 Jul 2017 20:29:25 +0300 Subject: [PATCH] Use std::iterator_traits to detect iterators, when possible. This allows next/prior to detect user's iterators that do not define iterator_category nested type but specialize std::iterator_traits instead. --- include/boost/next_prior.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/boost/next_prior.hpp b/include/boost/next_prior.hpp index bad46ed..178cf67 100644 --- a/include/boost/next_prior.hpp +++ b/include/boost/next_prior.hpp @@ -52,7 +52,16 @@ struct is_iterator }; template< typename T > -struct is_iterator< T, typename enable_if_has_type< typename T::iterator_category >::type > +struct is_iterator< + T, + typename enable_if_has_type< +#if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS) + typename std::iterator_traits< T >::iterator_category +#else + typename T::iterator_category +#endif + >::type +> { static BOOST_CONSTEXPR_OR_CONST bool value = true; };