mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-03 22:44:43 +02:00
Convert boost::iterator traversal tags into std tags to avoid unneeded overloads that confuse some older compilers like MSVC 12
This commit is contained in:
@@ -63,26 +63,59 @@ struct iterator
|
|||||||
typedef Reference reference;
|
typedef Reference reference;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// iterator_[dis|en]able_if_boost_iterator
|
// Conversion from boost::iterator traversals to std tags
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class I>
|
|
||||||
struct is_boost_iterator
|
template<class Tag>
|
||||||
|
struct get_std_category_from_tag
|
||||||
{
|
{
|
||||||
static const bool value = false;
|
typedef Tag type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Category, class Traversal>
|
template <class Category>
|
||||||
struct is_boost_iterator< boost::iterators::detail::iterator_category_with_traversal<Category, Traversal> >
|
struct get_std_category_from_tag
|
||||||
|
<boost::iterators::detail::iterator_category_with_traversal
|
||||||
|
<Category, boost::iterators::incrementable_traversal_tag> >
|
||||||
{
|
{
|
||||||
static const bool value = true;
|
typedef std::input_iterator_tag type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class I, class R = void>
|
template <class Category>
|
||||||
struct iterator_enable_if_boost_iterator
|
struct get_std_category_from_tag
|
||||||
: ::boost::move_detail::enable_if_c
|
<boost::iterators::detail::iterator_category_with_traversal
|
||||||
< is_boost_iterator<typename boost::intrusive::iterator_traits<I>::iterator_category >::value
|
<Category, boost::iterators::single_pass_traversal_tag> >
|
||||||
, R>
|
{
|
||||||
|
typedef std::input_iterator_tag type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Category>
|
||||||
|
struct get_std_category_from_tag
|
||||||
|
<boost::iterators::detail::iterator_category_with_traversal
|
||||||
|
<Category, boost::iterators::forward_traversal_tag> >
|
||||||
|
{
|
||||||
|
typedef std::input_iterator_tag type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Category>
|
||||||
|
struct get_std_category_from_tag
|
||||||
|
<boost::iterators::detail::iterator_category_with_traversal
|
||||||
|
<Category, boost::iterators::bidirectional_traversal_tag> >
|
||||||
|
{
|
||||||
|
typedef std::bidirectional_iterator_tag type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Category>
|
||||||
|
struct get_std_category_from_tag
|
||||||
|
<boost::iterators::detail::iterator_category_with_traversal
|
||||||
|
<Category, boost::iterators::random_access_traversal_tag> >
|
||||||
|
{
|
||||||
|
typedef std::random_access_iterator_tag type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class It>
|
||||||
|
struct get_std_category_from_it
|
||||||
|
: get_std_category_from_tag< typename boost::intrusive::iterator_traits<It>::iterator_category >
|
||||||
{};
|
{};
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
@@ -92,7 +125,7 @@ template<class I, class Tag, class R = void>
|
|||||||
struct iterator_enable_if_tag
|
struct iterator_enable_if_tag
|
||||||
: ::boost::move_detail::enable_if_c
|
: ::boost::move_detail::enable_if_c
|
||||||
< ::boost::move_detail::is_same
|
< ::boost::move_detail::is_same
|
||||||
< typename boost::intrusive::iterator_traits<I>::iterator_category
|
< typename get_std_category_from_it<I>::type
|
||||||
, Tag
|
, Tag
|
||||||
>::value
|
>::value
|
||||||
, R>
|
, R>
|
||||||
@@ -102,7 +135,7 @@ template<class I, class Tag, class R = void>
|
|||||||
struct iterator_disable_if_tag
|
struct iterator_disable_if_tag
|
||||||
: ::boost::move_detail::enable_if_c
|
: ::boost::move_detail::enable_if_c
|
||||||
< !::boost::move_detail::is_same
|
< !::boost::move_detail::is_same
|
||||||
< typename boost::intrusive::iterator_traits<I>::iterator_category
|
< typename get_std_category_from_it<I>::type
|
||||||
, Tag
|
, Tag
|
||||||
>::value
|
>::value
|
||||||
, R>
|
, R>
|
||||||
@@ -115,11 +148,11 @@ template<class I, class Tag, class Tag2, class R = void>
|
|||||||
struct iterator_enable_if_convertible_tag
|
struct iterator_enable_if_convertible_tag
|
||||||
: ::boost::move_detail::enable_if_c
|
: ::boost::move_detail::enable_if_c
|
||||||
< ::boost::move_detail::is_same_or_convertible
|
< ::boost::move_detail::is_same_or_convertible
|
||||||
< typename boost::intrusive::iterator_traits<I>::iterator_category
|
< typename get_std_category_from_it<I>::type
|
||||||
, Tag
|
, Tag
|
||||||
>::value &&
|
>::value &&
|
||||||
!::boost::move_detail::is_same_or_convertible
|
!::boost::move_detail::is_same_or_convertible
|
||||||
< typename boost::intrusive::iterator_traits<I>::iterator_category
|
< typename get_std_category_from_it<I>::type
|
||||||
, Tag2
|
, Tag2
|
||||||
>::value
|
>::value
|
||||||
, R>
|
, R>
|
||||||
@@ -175,54 +208,6 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_tag<InputIt, std::random
|
|||||||
it += n;
|
it += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class InputIt>
|
|
||||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag
|
|
||||||
<InputIt, const boost::iterators::incrementable_traversal_tag&, const boost::iterators::single_pass_traversal_tag&>::type
|
|
||||||
iterator_advance(InputIt& it, typename iterator_traits<InputIt>::difference_type n)
|
|
||||||
{
|
|
||||||
while(n--)
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class InputIt>
|
|
||||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag
|
|
||||||
<InputIt, const boost::iterators::single_pass_traversal_tag &, const boost::iterators::forward_traversal_tag&>::type
|
|
||||||
iterator_advance(InputIt& it, typename iterator_traits<InputIt>::difference_type n)
|
|
||||||
{
|
|
||||||
while(n--)
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class InputIt>
|
|
||||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag
|
|
||||||
<InputIt, const boost::iterators::forward_traversal_tag&, const boost::iterators::bidirectional_traversal_tag&>::type
|
|
||||||
iterator_advance(InputIt& it, typename iterator_traits<InputIt>::difference_type n)
|
|
||||||
{
|
|
||||||
while(n--)
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class InputIt>
|
|
||||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag
|
|
||||||
<InputIt, const boost::iterators::bidirectional_traversal_tag&, const boost::iterators::random_access_traversal_tag&>::type
|
|
||||||
iterator_advance(InputIt& it, typename iterator_traits<InputIt>::difference_type n)
|
|
||||||
{
|
|
||||||
for (; 0 < n; --n)
|
|
||||||
++it;
|
|
||||||
for (; n < 0; ++n)
|
|
||||||
--it;
|
|
||||||
}
|
|
||||||
|
|
||||||
class fake{};
|
|
||||||
|
|
||||||
template<class InputIt>
|
|
||||||
BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag
|
|
||||||
<InputIt, const boost::iterators::random_access_traversal_tag&, const fake&>::type
|
|
||||||
iterator_advance(InputIt& it, typename iterator_traits<InputIt>::difference_type n)
|
|
||||||
{
|
|
||||||
it += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class It>
|
template<class It>
|
||||||
BOOST_INTRUSIVE_FORCEINLINE
|
BOOST_INTRUSIVE_FORCEINLINE
|
||||||
void iterator_uadvance(It& it, typename iterator_traits<It>::size_type n)
|
void iterator_uadvance(It& it, typename iterator_traits<It>::size_type n)
|
||||||
|
Reference in New Issue
Block a user