Workaround for LWG 2408: SFINAE-friendly std::iterator_traits.

Now available for GCC(libstdc++v3) < 4.5 and MSVC 12.0.
It means, there is no ambiguous about calling next/prior/... via ADL.
This commit is contained in:
Kohei Takahashi
2015-02-05 23:04:36 +09:00
parent 5e4978b870
commit 6ab68a29d8
21 changed files with 202 additions and 0 deletions

View File

@ -109,4 +109,13 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Array, int Pos>
struct iterator_traits< ::boost::fusion::array_iterator<Array, Pos> >
{ };
}
#endif
#endif #endif

View File

@ -207,6 +207,15 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Cons>
struct iterator_traits< ::boost::fusion::boost_tuple_iterator<Cons> >
{ };
}
#endif
#endif #endif

View File

@ -114,6 +114,15 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Iterator>
struct iterator_traits< ::boost::fusion::mpl_iterator<Iterator> >
{ };
}
#endif
#endif #endif

View File

@ -106,6 +106,15 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Tuple, int Index>
struct iterator_traits< ::boost::fusion::std_tuple_iterator<Tuple, Index> >
{ };
}
#endif
#endif #endif

View File

@ -118,4 +118,13 @@ namespace boost { namespace fusion {
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Seq, int Pos>
struct iterator_traits< ::boost::fusion::deque_iterator<Seq, Pos> >
{ };
}
#endif
#endif #endif

View File

@ -98,4 +98,13 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Cons>
struct iterator_traits< ::boost::fusion::cons_iterator<Cons> >
{ };
}
#endif
#endif #endif

View File

@ -163,4 +163,13 @@ namespace boost { namespace fusion
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Seq, int Pos>
struct iterator_traits< ::boost::fusion::map_iterator<Seq, Pos> >
{ };
}
#endif
#endif #endif

View File

@ -48,5 +48,14 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Vector, int N>
struct iterator_traits< ::boost::fusion::vector_iterator<Vector, N> >
{ };
}
#endif
#endif #endif

View File

@ -144,4 +144,13 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Tag, typename Category, typename Seq, int Index>
struct iterator_traits< ::boost::fusion::basic_iterator<Tag, Category, Seq, Index> >
{ };
}
#endif
#endif #endif

View File

@ -135,4 +135,13 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Derived, typename Iterator, typename Category>
struct iterator_traits< ::boost::fusion::iterator_adapter<Derived, Iterator, Category> >
{ };
}
#endif
#endif #endif

View File

@ -56,4 +56,13 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Derived, typename Category>
struct iterator_traits< ::boost::fusion::iterator_facade<Derived, Category> >
{ };
}
#endif
#endif #endif

View File

@ -68,4 +68,23 @@ namespace boost { namespace fusion { namespace detail
# define BOOST_FUSION_FWD_ELEM(type, value) std::forward<type>(value) # define BOOST_FUSION_FWD_ELEM(type, value) std::forward<type>(value)
#endif #endif
// Workaround for LWG 2408: C++17 SFINAE-friendly std::iterator_traits.
// http://cplusplus.github.io/LWG/lwg-defects.html#2408
//
// - GCC 4.5 enables the feature under C++11.
// https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01105.html
//
// - Only MSVC 12.0 doesn't have the feature.
#if (defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 40500) && \
defined(BOOST_LIBSTDCXX11)) || \
(defined(BOOST_MSVC) && (BOOST_MSVC == 1800))
# define BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename>
struct iterator_traits;
}
#endif
#endif #endif

View File

@ -67,6 +67,15 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Category, typename First, typename Last, typename Pred>
struct iterator_traits< ::boost::fusion::filter_iterator<Category, First, Last, Pred> >
{ };
}
#endif
#endif #endif

View File

@ -194,6 +194,15 @@ namespace boost { namespace fusion { namespace extension
}; };
}}} }}}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename First, typename Base>
struct iterator_traits< ::boost::fusion::flatten_view_iterator<First, Base> >
{ };
}
#endif
#endif #endif

View File

@ -56,6 +56,15 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Category, typename First, typename Last, typename Concat>
struct iterator_traits< ::boost::fusion::joint_view_iterator<Category, First, Last, Concat> >
{ };
}
#endif
#endif #endif

View File

@ -54,6 +54,15 @@ namespace boost { namespace fusion
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Sequence, typename Pos>
struct iterator_traits< ::boost::fusion::nview_iterator<Sequence, Pos> >
{ };
}
#endif
#endif #endif

View File

@ -53,5 +53,14 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Sequence, typename Pos>
struct iterator_traits< ::boost::fusion::repetitive_view_iterator<Sequence, Pos> >
{ };
}
#endif
#endif #endif

View File

@ -54,5 +54,14 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename First>
struct iterator_traits< ::boost::fusion::reverse_view_iterator<First> >
{ };
}
#endif
#endif #endif

View File

@ -50,6 +50,15 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename SingleView, typename Pos>
struct iterator_traits< ::boost::fusion::single_view_iterator<SingleView, Pos> >
{ };
}
#endif
#if defined (BOOST_MSVC) #if defined (BOOST_MSVC)
# pragma warning(pop) # pragma warning(pop)
#endif #endif

View File

@ -76,5 +76,17 @@ namespace boost { namespace fusion
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename First, typename F>
struct iterator_traits< ::boost::fusion::transform_view_iterator<First, F> >
{ };
template <typename First1, typename First2, typename F>
struct iterator_traits< ::boost::fusion::transform_view_iterator2<First1, First2, F> >
{ };
}
#endif
#endif #endif

View File

@ -46,4 +46,13 @@ namespace boost { namespace fusion {
}; };
}} }}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename IteratorSequence, typename Traversal>
struct iterator_traits< ::boost::fusion::zip_view_iterator<IteratorSequence, Traversal> >
{ };
}
#endif
#endif #endif