From 6ab68a29d8518e43d7efd1002dd7e12a590191e9 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 5 Feb 2015 23:04:36 +0900 Subject: [PATCH] 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. --- .../adapted/boost_array/array_iterator.hpp | 9 +++++++++ .../boost_tuple/boost_tuple_iterator.hpp | 9 +++++++++ .../boost/fusion/adapted/mpl/mpl_iterator.hpp | 9 +++++++++ .../adapted/std_tuple/std_tuple_iterator.hpp | 9 +++++++++ .../fusion/container/deque/deque_iterator.hpp | 9 +++++++++ .../fusion/container/list/cons_iterator.hpp | 9 +++++++++ .../fusion/container/map/map_iterator.hpp | 9 +++++++++ .../container/vector/vector_iterator.hpp | 9 +++++++++ .../boost/fusion/iterator/basic_iterator.hpp | 9 +++++++++ .../fusion/iterator/iterator_adapter.hpp | 9 +++++++++ .../boost/fusion/iterator/iterator_facade.hpp | 9 +++++++++ include/boost/fusion/support/config.hpp | 19 +++++++++++++++++++ .../view/filter_view/filter_view_iterator.hpp | 9 +++++++++ .../flatten_view/flatten_view_iterator.hpp | 9 +++++++++ .../view/joint_view/joint_view_iterator.hpp | 9 +++++++++ .../fusion/view/nview/nview_iterator.hpp | 9 +++++++++ .../repetitive_view_iterator.hpp | 9 +++++++++ .../reverse_view/reverse_view_iterator.hpp | 9 +++++++++ .../view/single_view/single_view_iterator.hpp | 9 +++++++++ .../transform_view_iterator.hpp | 12 ++++++++++++ .../view/zip_view/zip_view_iterator.hpp | 9 +++++++++ 21 files changed, 202 insertions(+) diff --git a/include/boost/fusion/adapted/boost_array/array_iterator.hpp b/include/boost/fusion/adapted/boost_array/array_iterator.hpp index 0e39d457..2002e2cc 100644 --- a/include/boost/fusion/adapted/boost_array/array_iterator.hpp +++ b/include/boost/fusion/adapted/boost_array/array_iterator.hpp @@ -109,4 +109,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::array_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp b/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp index 40c5d79c..850eef5f 100644 --- a/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp +++ b/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp @@ -207,6 +207,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::boost_tuple_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/mpl/mpl_iterator.hpp b/include/boost/fusion/adapted/mpl/mpl_iterator.hpp index 43748d98..87de32ad 100644 --- a/include/boost/fusion/adapted/mpl/mpl_iterator.hpp +++ b/include/boost/fusion/adapted/mpl/mpl_iterator.hpp @@ -114,6 +114,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::mpl_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp b/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp index c4d957ea..0ae4ae77 100644 --- a/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp +++ b/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp @@ -106,6 +106,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::std_tuple_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/deque/deque_iterator.hpp b/include/boost/fusion/container/deque/deque_iterator.hpp index f603b545..2b06bd8c 100644 --- a/include/boost/fusion/container/deque/deque_iterator.hpp +++ b/include/boost/fusion/container/deque/deque_iterator.hpp @@ -118,4 +118,13 @@ namespace boost { namespace fusion { }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::deque_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/list/cons_iterator.hpp b/include/boost/fusion/container/list/cons_iterator.hpp index da694756..0c3ec668 100644 --- a/include/boost/fusion/container/list/cons_iterator.hpp +++ b/include/boost/fusion/container/list/cons_iterator.hpp @@ -98,4 +98,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::cons_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/map/map_iterator.hpp b/include/boost/fusion/container/map/map_iterator.hpp index 4927e155..b79dd1da 100644 --- a/include/boost/fusion/container/map/map_iterator.hpp +++ b/include/boost/fusion/container/map/map_iterator.hpp @@ -163,4 +163,13 @@ namespace boost { namespace fusion }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::map_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/vector/vector_iterator.hpp b/include/boost/fusion/container/vector/vector_iterator.hpp index ffa4d138..8e586c54 100644 --- a/include/boost/fusion/container/vector/vector_iterator.hpp +++ b/include/boost/fusion/container/vector/vector_iterator.hpp @@ -48,5 +48,14 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::vector_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/iterator/basic_iterator.hpp b/include/boost/fusion/iterator/basic_iterator.hpp index 5d484132..eae46e63 100644 --- a/include/boost/fusion/iterator/basic_iterator.hpp +++ b/include/boost/fusion/iterator/basic_iterator.hpp @@ -144,4 +144,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::basic_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/iterator/iterator_adapter.hpp b/include/boost/fusion/iterator/iterator_adapter.hpp index 7e860c77..de8938f6 100644 --- a/include/boost/fusion/iterator/iterator_adapter.hpp +++ b/include/boost/fusion/iterator/iterator_adapter.hpp @@ -135,4 +135,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::iterator_adapter > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/iterator/iterator_facade.hpp b/include/boost/fusion/iterator/iterator_facade.hpp index a2c659ab..1760957e 100644 --- a/include/boost/fusion/iterator/iterator_facade.hpp +++ b/include/boost/fusion/iterator/iterator_facade.hpp @@ -56,4 +56,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::iterator_facade > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/support/config.hpp b/include/boost/fusion/support/config.hpp index 15d4be6e..924c2ff1 100644 --- a/include/boost/fusion/support/config.hpp +++ b/include/boost/fusion/support/config.hpp @@ -68,4 +68,23 @@ namespace boost { namespace fusion { namespace detail # define BOOST_FUSION_FWD_ELEM(type, value) std::forward(value) #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 + struct iterator_traits; +} +#endif + #endif diff --git a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp index 14aaa460..d407c9da 100644 --- a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp +++ b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp @@ -67,6 +67,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::filter_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp index dfe613ac..e47868c1 100644 --- a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp +++ b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp @@ -194,6 +194,15 @@ namespace boost { namespace fusion { namespace extension }; }}} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::flatten_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/joint_view/joint_view_iterator.hpp b/include/boost/fusion/view/joint_view/joint_view_iterator.hpp index 98584740..d73a24fd 100644 --- a/include/boost/fusion/view/joint_view/joint_view_iterator.hpp +++ b/include/boost/fusion/view/joint_view/joint_view_iterator.hpp @@ -56,6 +56,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::joint_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/nview/nview_iterator.hpp b/include/boost/fusion/view/nview/nview_iterator.hpp index c614cbbb..b1111e84 100644 --- a/include/boost/fusion/view/nview/nview_iterator.hpp +++ b/include/boost/fusion/view/nview/nview_iterator.hpp @@ -54,6 +54,15 @@ namespace boost { namespace fusion }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::nview_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp b/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp index b9f45d0c..ea9e491e 100644 --- a/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp +++ b/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp @@ -53,5 +53,14 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::repetitive_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp b/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp index 9de2169e..b773f15d 100644 --- a/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp +++ b/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp @@ -54,5 +54,14 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::reverse_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/single_view/single_view_iterator.hpp b/include/boost/fusion/view/single_view/single_view_iterator.hpp index 128c1cae..50c15466 100644 --- a/include/boost/fusion/view/single_view/single_view_iterator.hpp +++ b/include/boost/fusion/view/single_view/single_view_iterator.hpp @@ -50,6 +50,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::single_view_iterator > + { }; +} +#endif + #if defined (BOOST_MSVC) # pragma warning(pop) #endif diff --git a/include/boost/fusion/view/transform_view/transform_view_iterator.hpp b/include/boost/fusion/view/transform_view/transform_view_iterator.hpp index 0762228f..19310fe1 100644 --- a/include/boost/fusion/view/transform_view/transform_view_iterator.hpp +++ b/include/boost/fusion/view/transform_view/transform_view_iterator.hpp @@ -76,5 +76,17 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::transform_view_iterator > + { }; + template + struct iterator_traits< ::boost::fusion::transform_view_iterator2 > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/zip_view/zip_view_iterator.hpp b/include/boost/fusion/view/zip_view/zip_view_iterator.hpp index fec50e6f..16b2ca74 100644 --- a/include/boost/fusion/view/zip_view/zip_view_iterator.hpp +++ b/include/boost/fusion/view/zip_view/zip_view_iterator.hpp @@ -46,4 +46,13 @@ namespace boost { namespace fusion { }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::zip_view_iterator > + { }; +} +#endif + #endif