From 0be2758375b6c34f5ef3a6a21cc9f609727755c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 30 Dec 2021 23:08:53 +0100 Subject: [PATCH] Convert boost::iterator traversal tags into std tags to avoid unneeded overloads that confuse some older compilers like MSVC 12 --- include/boost/intrusive/detail/iterator.hpp | 117 +++++++++----------- 1 file changed, 51 insertions(+), 66 deletions(-) diff --git a/include/boost/intrusive/detail/iterator.hpp b/include/boost/intrusive/detail/iterator.hpp index 61840da..86da5aa 100644 --- a/include/boost/intrusive/detail/iterator.hpp +++ b/include/boost/intrusive/detail/iterator.hpp @@ -63,26 +63,59 @@ struct iterator typedef Reference reference; }; -//////////////////////////////////////// -// iterator_[dis|en]able_if_boost_iterator -//////////////////////////////////////// -template -struct is_boost_iterator +//////////////////////////////////////////////////////////////////////////////// +// Conversion from boost::iterator traversals to std tags +//////////////////////////////////////////////////////////////////////////////// + +template +struct get_std_category_from_tag { - static const bool value = false; + typedef Tag type; }; -template -struct is_boost_iterator< boost::iterators::detail::iterator_category_with_traversal > +template +struct get_std_category_from_tag + > { - static const bool value = true; + typedef std::input_iterator_tag type; }; -template -struct iterator_enable_if_boost_iterator - : ::boost::move_detail::enable_if_c - < is_boost_iterator::iterator_category >::value - , R> +template +struct get_std_category_from_tag + > +{ + typedef std::input_iterator_tag type; +}; + +template +struct get_std_category_from_tag + > +{ + typedef std::input_iterator_tag type; +}; + +template +struct get_std_category_from_tag + > +{ + typedef std::bidirectional_iterator_tag type; +}; + +template +struct get_std_category_from_tag + > +{ + typedef std::random_access_iterator_tag type; +}; + +template +struct get_std_category_from_it + : get_std_category_from_tag< typename boost::intrusive::iterator_traits::iterator_category > {}; //////////////////////////////////////// @@ -92,7 +125,7 @@ template struct iterator_enable_if_tag : ::boost::move_detail::enable_if_c < ::boost::move_detail::is_same - < typename boost::intrusive::iterator_traits::iterator_category + < typename get_std_category_from_it::type , Tag >::value , R> @@ -102,7 +135,7 @@ template struct iterator_disable_if_tag : ::boost::move_detail::enable_if_c < !::boost::move_detail::is_same - < typename boost::intrusive::iterator_traits::iterator_category + < typename get_std_category_from_it::type , Tag >::value , R> @@ -115,11 +148,11 @@ template struct iterator_enable_if_convertible_tag : ::boost::move_detail::enable_if_c < ::boost::move_detail::is_same_or_convertible - < typename boost::intrusive::iterator_traits::iterator_category + < typename get_std_category_from_it::type , Tag >::value && !::boost::move_detail::is_same_or_convertible - < typename boost::intrusive::iterator_traits::iterator_category + < typename get_std_category_from_it::type , Tag2 >::value , R> @@ -175,54 +208,6 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_tag -BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag - ::type - iterator_advance(InputIt& it, typename iterator_traits::difference_type n) -{ - while(n--) - ++it; -} - -template -BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag - ::type - iterator_advance(InputIt& it, typename iterator_traits::difference_type n) -{ - while(n--) - ++it; -} - -template -BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag - ::type - iterator_advance(InputIt& it, typename iterator_traits::difference_type n) -{ - while(n--) - ++it; -} - -template -BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag - ::type - iterator_advance(InputIt& it, typename iterator_traits::difference_type n) -{ - for (; 0 < n; --n) - ++it; - for (; n < 0; ++n) - --it; -} - -class fake{}; - -template -BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag - ::type - iterator_advance(InputIt& it, typename iterator_traits::difference_type n) -{ - it += n; -} - template BOOST_INTRUSIVE_FORCEINLINE void iterator_uadvance(It& it, typename iterator_traits::size_type n)