From df5aaeaa668118e68fba24ac500acfe5db856711 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 21 Jan 2001 05:18:41 +0000 Subject: [PATCH 01/37] Initial checkin [SVN r8664] --- include/boost/detail/iterator.hpp | 207 ++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 include/boost/detail/iterator.hpp diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp new file mode 100644 index 0000000..8652b8f --- /dev/null +++ b/include/boost/detail/iterator.hpp @@ -0,0 +1,207 @@ +// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. + +// Boost versions of +// +// std::iterator_traits<>::iterator_category +// std::iterator_traits<>::difference_type +// std::distance() +// +// ...for all compilers and iterators + +#ifndef ITERATOR_DWA122600_HPP_ +# define ITERATOR_DWA122600_HPP_ + +# include +# include +# include +# include + +// STLPort 4.0 and betas have a bug when debugging is enabled and there is no +// partial specialization: instead of an iterator_category typedef, the standard +// container iterators have _Iterator_category. +// +// Also, whether debugging is enabled or not, there is a broken specialization +// of std::iterator which has no +// typedefs but iterator_category. +// the proper typedef. +# if defined(__SGI_STL_PORT) && (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) + +# ifdef __STL_DEBUG +# define BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# endif + +# define BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION + +# endif // STLPort <= 4.1b4 && no partial specialization + +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif + +namespace boost { namespace detail { +# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +using std::iterator_traits; +using std::distance; +# else +// Workarounds for less-capable implementations +template struct iterator_traits_select; +template <> struct iterator_traits_select +{ + template + struct traits + { + typedef std::ptrdiff_t difference_type; + typedef std::random_access_iterator_tag iterator_category; + }; +}; + + +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +no_result bad_category_helper(...); +template yes_result bad_category_helper(std::_DBG_iter*); + +template struct bad_category_select; +template <> +struct bad_category_select +{ + template + struct category { typedef typename Iterator::_Iterator_category type; }; +}; +template <> +struct bad_category_select +{ + template + struct category { typedef typename Iterator::iterator_category type; }; +}; + +template +struct iterator_category_select +{ + private: + static Iterator p; + enum { has_bad_category + = sizeof(bad_category_helper(&p)) == sizeof(yes_result) }; + typedef bad_category_select category_select; + public: + typedef typename category_select::template category::type type; +}; + +# endif + +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION +template struct bad_difference_select; +template <> +struct bad_difference_select +{ + template + struct difference { typedef void type; }; +}; +template <> +struct bad_difference_select +{ + template + struct difference { typedef typename Iterator::difference_type type; }; +}; +yes_result bad_output_iterator_helper(std::iterator*); +no_result bad_output_iterator_helper(...); +# endif + +template <> struct iterator_traits_select +{ + template + struct traits +# if defined(BOOST_NO_STD_ITERATOR_TRAITS) + { +# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) + typedef typename Iterator::distance_type difference_type; +# elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) + typedef typename Iterator::difference_type difference_type; +# else + private: + // static Iterator *p; + typedef bad_difference_select< + is_convertible* + >::value> difference_type_select; + public: + typedef typename difference_type_select::template difference::type difference_type; +# endif + +# if !defined(BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF) + typedef typename Iterator::iterator_category iterator_category; +# else + typedef typename iterator_category_select::type iterator_category; +# endif + }; +# else + { + typedef typename std::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::iterator_category iterator_category; + }; +# endif +}; + +template +struct iterator_traits +{ + private: + typedef iterator_traits_select::type>::value> select; + typedef typename select::template traits traits; + public: + typedef typename traits::difference_type difference_type; + typedef typename traits::iterator_category iterator_category; +}; + +template +struct distance_select { + template + static typename ::boost::detail::iterator_traits::difference_type + distance(Iterator i1, const Iterator i2) + { + typename ::boost::detail::iterator_traits::difference_type result = 0; + while (i1 != i2) + { + ++i1; + ++result; + } + return result; + } +}; + +template <> +struct distance_select { + template + static typename ::boost::detail::iterator_traits::difference_type + distance(const Iterator i1, const Iterator i2) + { + return i2 - i1; + } +}; + +template +inline typename ::boost::detail::iterator_traits::difference_type +distance(const Iterator& first, const Iterator& last) +{ + typedef typename ::boost::detail::iterator_traits::iterator_category iterator_category; + return distance_select::distance(first, last); +} +# endif // workarounds + +}} + +# undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION + +#endif // ITERATOR_DWA122600_HPP_ From 9f0afd5ab4716e77c27cda3af42389fab806646d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 21 Jan 2001 16:18:41 +0000 Subject: [PATCH 02/37] tweak a comment [SVN r8680] --- include/boost/detail/iterator.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 8652b8f..17b3344 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -27,7 +27,6 @@ // Also, whether debugging is enabled or not, there is a broken specialization // of std::iterator which has no // typedefs but iterator_category. -// the proper typedef. # if defined(__SGI_STL_PORT) && (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) # ifdef __STL_DEBUG From c95e13e60221f5d6543173778eae25b9bdd9b7e0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Feb 2001 04:52:58 +0000 Subject: [PATCH 03/37] Removed useless #includes of standard library headers [SVN r8993] --- include/boost/detail/iterator.hpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 17b3344..5c4ea17 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -11,6 +11,13 @@ // std::distance() // // ...for all compilers and iterators +// + +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 06 Feb 2001 - Removed useless #includes of standard library headers +// (David Abrahams) #ifndef ITERATOR_DWA122600_HPP_ # define ITERATOR_DWA122600_HPP_ @@ -37,18 +44,6 @@ # endif // STLPort <= 4.1b4 && no partial specialization -# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF -# include -# include -# include -# include -# include -# include -# include -# include -# include -# endif - namespace boost { namespace detail { # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) using std::iterator_traits; From 61cf75c446645af5cc06f33a2e406e8c4a0cfe5c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Feb 2001 16:43:57 +0000 Subject: [PATCH 04/37] Added support for more of the traits members where possible, making this useful as a replacement for std::iterator_traits when used as a default template parameter. [SVN r9002] --- include/boost/detail/iterator.hpp | 60 +++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 5c4ea17..4376006 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -12,10 +12,20 @@ // // ...for all compilers and iterators // +// Additionally, if partial specialization is supported or X is not a pointer +// std::iterator_traits::value_type +// +// And if partial specialization is supported or (X is not a pointer and the +// library isn't the VC6 standard library), +// std::iterator_traits::pointer +// std::iterator_traits::reference // See http://www.boost.org for most recent version including documentation. // Revision History +// 07 Feb 2001 - Support for more of the traits members where possible, making +// this useful as a replacement for std::iterator_traits when +// used as a default template parameter. // 06 Feb 2001 - Removed useless #includes of standard library headers // (David Abrahams) @@ -49,8 +59,10 @@ namespace boost { namespace detail { using std::iterator_traits; using std::distance; # else + // Workarounds for less-capable implementations template struct iterator_traits_select; + template <> struct iterator_traits_select { template @@ -95,23 +107,33 @@ struct iterator_category_select # endif # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION -template struct bad_difference_select; +template struct bad_output_iterator_select; template <> -struct bad_difference_select +struct bad_output_iterator_select { template - struct difference { typedef void type; }; + struct non_category_traits { + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + }; }; template <> -struct bad_difference_select +struct bad_output_iterator_select { template - struct difference { typedef typename Iterator::difference_type type; }; + struct non_category_traits { + typedef typename Iterator::value_type value_type; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + }; }; -yes_result bad_output_iterator_helper(std::iterator*); -no_result bad_output_iterator_helper(...); # endif +template struct undefined; + template <> struct iterator_traits_select { template @@ -120,17 +142,24 @@ template <> struct iterator_traits_select { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; # elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; # else - private: - // static Iterator *p; - typedef bad_difference_select< + typedef bad_output_iterator_select< is_convertible* - >::value> difference_type_select; + >::value> non_category_traits_select; + typedef non_category_traits_select::template non_category_traits non_category_traits; public: - typedef typename difference_type_select::template difference::type difference_type; + typedef typename non_category_traits::value_type value_type; + typedef typename non_category_traits::difference_type difference_type; + typedef typename non_category_traits::pointer pointer; + typedef typename non_category_traits::reference reference; # endif # if !defined(BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF) @@ -149,11 +178,14 @@ template <> struct iterator_traits_select template struct iterator_traits + : iterator_traits_select::type>::value>::template traits { private: - typedef iterator_traits_select::type>::value> select; - typedef typename select::template traits traits; + typedef typename iterator_traits_select< + is_pointer::type>::value>::template traits traits; public: + // Why do I need to define these typedefs? It keeps MSVC happy somehow. + // Why don't I need to define the other typedefs? Who knows?!? typedef typename traits::difference_type difference_type; typedef typename traits::iterator_category iterator_category; }; From 61cc24992c81a54c12377c53d1d1029b28e4cac8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 10 Feb 2001 00:05:17 +0000 Subject: [PATCH 05/37] Always have a definition for each traits member, even if it can't be properly deduced. These will be incomplete types in some cases (undefined), but it helps suppress MSVC errors elsewhere [SVN r9064] --- include/boost/detail/iterator.hpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 4376006..eb8f692 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 09 Feb 2001 - Always have a definition for each traits member, even if it +// can't be properly deduced. These will be incomplete types in +// some cases (undefined), but it helps suppress MSVC errors +// elsewhere (David Abrahams) // 07 Feb 2001 - Support for more of the traits members where possible, making // this useful as a replacement for std::iterator_traits when // used as a default template parameter. @@ -63,6 +67,7 @@ using std::distance; // Workarounds for less-capable implementations template struct iterator_traits_select; +template struct undefined; template <> struct iterator_traits_select { template @@ -70,6 +75,14 @@ template <> struct iterator_traits_select { typedef std::ptrdiff_t difference_type; typedef std::random_access_iterator_tag iterator_category; +#ifdef BOOST_MSVC +// Keeps MSVC happy under certain circumstances. It seems class template default +// arguments are partly instantiated even when not used when the class template +// is the return type of a function template. + typedef undefined value_type; + typedef undefined pointer; + typedef undefined reference; +#endif }; }; @@ -132,8 +145,6 @@ struct bad_output_iterator_select }; # endif -template struct undefined; - template <> struct iterator_traits_select { template @@ -143,6 +154,10 @@ template <> struct iterator_traits_select # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef typename Iterator::distance_type difference_type; typedef typename Iterator::value_type value_type; +#ifdef BOOST_MSVC // Keeps MSVC happy under certain circumstances + typedef undefined pointer; + typedef undefined reference; +#endif # elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; From 6d431c2f59b261437b9c3687ab1a0becdf854828 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 11 Feb 2001 19:44:54 +0000 Subject: [PATCH 06/37] Clean away code which can never be used [SVN r9134] --- include/boost/detail/iterator.hpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index eb8f692..9c21037 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,7 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 11 Feb 2001 - Clean away code which can never be used (David Abrahams) // 09 Feb 2001 - Always have a definition for each traits member, even if it // can't be properly deduced. These will be incomplete types in // some cases (undefined), but it helps suppress MSVC errors @@ -149,7 +150,6 @@ template <> struct iterator_traits_select { template struct traits -# if defined(BOOST_NO_STD_ITERATOR_TRAITS) { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef typename Iterator::distance_type difference_type; @@ -183,12 +183,6 @@ template <> struct iterator_traits_select typedef typename iterator_category_select::type iterator_category; # endif }; -# else - { - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::iterator_category iterator_category; - }; -# endif }; template From a9ac96bfd7b997b83ebd059af1f979d758f8d5d8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 13 Feb 2001 23:30:25 +0000 Subject: [PATCH 07/37] Make it work with standard conforming iterators under raw VC6. [SVN r9197] --- include/boost/detail/iterator.hpp | 63 ++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 9c21037..7b73d68 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 13 Feb 2001 - Make it work with nearly all standard-conforming iterators +// under raw VC6. The one category remaining which will fail is +// that of iterators derived from std::iterator but not +// boost::iterator and which redefine difference_type. // 11 Feb 2001 - Clean away code which can never be used (David Abrahams) // 09 Feb 2001 - Always have a definition for each traits member, even if it // can't be properly deduced. These will be incomplete types in @@ -39,6 +43,7 @@ # include # include +# include # include # include @@ -146,18 +151,64 @@ struct bad_output_iterator_select }; # endif +# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +template struct msvc_traits_select; + +template <> struct msvc_traits_select +{ + template + struct traits_ // calling this "traits" will confuse VC. + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef undefined pointer; + typedef undefined reference; + }; +}; + +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + }; +}; + +template +yes_result is_std_iterator_helper(const volatile std::iterator*); +no_result is_std_iterator_helper(...); + +template +yes_result is_boost_iterator_helper(const volatile boost::iterator*); +no_result is_boost_iterator_helper(...); + +template +struct has_msvc_std_iterator_traits +{ + BOOST_STATIC_CONSTANT(bool, value = + (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_result) + && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_result))); +}; +# endif + template <> struct iterator_traits_select { template struct traits { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; -#ifdef BOOST_MSVC // Keeps MSVC happy under certain circumstances - typedef undefined pointer; - typedef undefined reference; -#endif + typedef msvc_traits_select<( + has_msvc_std_iterator_traits::value + )>::template traits_ inner_traits; + + typedef typename inner_traits::difference_type difference_type; + typedef typename inner_traits::value_type value_type; + typedef typename inner_traits::pointer pointer; + typedef typename inner_traits::reference reference; # elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; From 44cfd8169ec0e5633ef7b81aa387970534725c27 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 18 Feb 2001 11:43:01 +0000 Subject: [PATCH 08/37] type_traits: regression failure fixes from type traits changes... [SVN r9249] --- include/boost/detail/iterator.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 7b73d68..0d9ceff 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -70,6 +70,9 @@ using std::iterator_traits; using std::distance; # else +typedef char yes_result; +typedef double no_result; + // Workarounds for less-capable implementations template struct iterator_traits_select; From 7f45ee1e71a589e4a31d92295e0a0a6ec0997d83 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 19 Feb 2001 22:51:32 +0000 Subject: [PATCH 09/37] Improved workarounds for stock MSVC6; use yes_type and no_type from type_traits.hpp; stopped trying to remove_cv before detecting is_pointer, in honor of the new type_traits semantics. [SVN r9282] --- include/boost/detail/iterator.hpp | 133 ++++++++++++++++++++++-------- 1 file changed, 100 insertions(+), 33 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 0d9ceff..29b4346 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 19 Feb 2001 - Improved workarounds for stock MSVC6; use yes_type and +// no_type from type_traits.hpp; stopped trying to remove_cv +// before detecting is_pointer, in honor of the new type_traits +// semantics. (David Abrahams) // 13 Feb 2001 - Make it work with nearly all standard-conforming iterators // under raw VC6. The one category remaining which will fail is // that of iterators derived from std::iterator but not @@ -47,6 +51,13 @@ # include # include +# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +# include +# include +# include +# endif + + // STLPort 4.0 and betas have a bug when debugging is enabled and there is no // partial specialization: instead of an iterator_category typedef, the standard // container iterators have _Iterator_category. @@ -70,9 +81,6 @@ using std::iterator_traits; using std::distance; # else -typedef char yes_result; -typedef double no_result; - // Workarounds for less-capable implementations template struct iterator_traits_select; @@ -84,12 +92,12 @@ template <> struct iterator_traits_select { typedef std::ptrdiff_t difference_type; typedef std::random_access_iterator_tag iterator_category; + typedef Ptr pointer; #ifdef BOOST_MSVC // Keeps MSVC happy under certain circumstances. It seems class template default // arguments are partly instantiated even when not used when the class template // is the return type of a function template. typedef undefined value_type; - typedef undefined pointer; typedef undefined reference; #endif }; @@ -97,8 +105,8 @@ template <> struct iterator_traits_select # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF -no_result bad_category_helper(...); -template yes_result bad_category_helper(std::_DBG_iter*); +no_type bad_category_helper(...); +template yes_type bad_category_helper(std::_DBG_iter*); template struct bad_category_select; template <> @@ -120,7 +128,7 @@ struct iterator_category_select private: static Iterator p; enum { has_bad_category - = sizeof(bad_category_helper(&p)) == sizeof(yes_result) }; + = sizeof(bad_category_helper(&p)) == sizeof(yes_type) }; typedef bad_category_select category_select; public: typedef typename category_select::template category::type type; @@ -155,24 +163,22 @@ struct bad_output_iterator_select # endif # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) -template struct msvc_traits_select; -template <> struct msvc_traits_select +// We'll sort iterator types into one of these classifications, from which we +// can determine the difference_type, pointer, reference, and value_type +enum { + not_msvc_stdlib_iterator, + msvc_stdlib_const_iterator, + msvc_stdlib_mutable_iterator, + msvc_stdlib_ostream_iterator +}; + +template struct msvc_traits_select; + +template <> struct msvc_traits_select { template struct traits_ // calling this "traits" will confuse VC. - { - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; - typedef undefined pointer; - typedef undefined reference; - }; -}; - -template <> struct msvc_traits_select -{ - template - struct traits_ { typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; @@ -181,20 +187,81 @@ template <> struct msvc_traits_select }; }; -template -yes_result is_std_iterator_helper(const volatile std::iterator*); -no_result is_std_iterator_helper(...); +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef value_type* pointer; + typedef value_type& reference; + }; +}; +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef const value_type* pointer; + typedef const value_type& reference; + }; +}; + +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef void pointer; + typedef void reference; + }; +}; + +// These functions allow us to detect which classification a given iterator type +// falls into. + +// Is the iterator derived from std::iterator? +template +yes_type is_std_iterator_helper(const volatile std::iterator*); +no_type is_std_iterator_helper(...); + +// Is the iterator derived from boost::iterator? template -yes_result is_boost_iterator_helper(const volatile boost::iterator*); -no_result is_boost_iterator_helper(...); +yes_type is_boost_iterator_helper(const volatile boost::iterator*); +no_type is_boost_iterator_helper(...); + +// Is the iterator one of the known mutable container iterators? +template +yes_type is_mutable_iterator_helper(const volatile std::_Tree::iterator*); +template +yes_type is_mutable_iterator_helper(const volatile std::list::iterator*); +template +yes_type is_mutable_iterator_helper(const volatile std::deque::iterator*); +no_type is_mutable_iterator_helper(...); + +// Is the iterator an ostream_iterator? +template +yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator*); +no_type is_ostream_iterator_helper(...); template -struct has_msvc_std_iterator_traits -{ - BOOST_STATIC_CONSTANT(bool, value = - (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_result) - && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_result))); +struct msvc_iterator_classification { + enum { + value = (sizeof(is_ostream_iterator_helper((T*)0)) == sizeof(yes_type)) + ? msvc_stdlib_ostream_iterator + : (sizeof(is_mutable_iterator_helper((T*)0)) == sizeof(yes_type)) + ? msvc_stdlib_mutable_iterator + : (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_type) + && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_type)) + ? msvc_stdlib_const_iterator + : not_msvc_stdlib_iterator + }; }; # endif @@ -205,7 +272,7 @@ template <> struct iterator_traits_select { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef msvc_traits_select<( - has_msvc_std_iterator_traits::value + msvc_iterator_classification::value )>::template traits_ inner_traits; typedef typename inner_traits::difference_type difference_type; @@ -241,7 +308,7 @@ template <> struct iterator_traits_select template struct iterator_traits - : iterator_traits_select::type>::value>::template traits + : iterator_traits_select::value>::template traits { private: typedef typename iterator_traits_select< From 4a34ab8b4d3f0f85160b269b330d68b3e66bbd7e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 19 Feb 2001 22:58:12 +0000 Subject: [PATCH 10/37] Updated documentation [SVN r9283] --- include/boost/detail/iterator.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 29b4346..df8bf36 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -12,13 +12,18 @@ // // ...for all compilers and iterators // -// Additionally, if partial specialization is supported or X is not a pointer +// Additionally, if X is a pointer +// std::iterator_traits::pointer + +// Otherwise, if partial specialization is supported or X is not a pointer // std::iterator_traits::value_type -// -// And if partial specialization is supported or (X is not a pointer and the -// library isn't the VC6 standard library), // std::iterator_traits::pointer // std::iterator_traits::reference +// +// CAVEAT: When using the VC6 standard library, an iterator derived from +// std::iterator but not boost::iterator or from one supplied by the standard +// will always have pointer == const value_type* and reference == const +// value_type&, whether that's correct or not. // See http://www.boost.org for most recent version including documentation. From 888c0d47ffc1534497b11aba0e87981d15799889 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Fri, 2 Mar 2001 23:45:03 +0000 Subject: [PATCH 11/37] Changed BOOST_MSVC to BOOST_MSVC_STD_ITERATOR in a few places. [SVN r9383] --- include/boost/detail/iterator.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index df8bf36..af238af 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -28,6 +28,8 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 02 Mar 2001 - Changed BOOST_MSVC to BOOST_MSVC_STD_ITERATOR in a few +// places. (Jeremy Siek) // 19 Feb 2001 - Improved workarounds for stock MSVC6; use yes_type and // no_type from type_traits.hpp; stopped trying to remove_cv // before detecting is_pointer, in honor of the new type_traits @@ -167,7 +169,7 @@ struct bad_output_iterator_select }; # endif -# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +# if defined(BOOST_MSVC_STD_ITERATOR) // We'll sort iterator types into one of these classifications, from which we // can determine the difference_type, pointer, reference, and value_type @@ -275,7 +277,7 @@ template <> struct iterator_traits_select template struct traits { -# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +# if defined(BOOST_MSVC_STD_ITERATOR) typedef msvc_traits_select<( msvc_iterator_classification::value )>::template traits_ inner_traits; From d9767cc6c6d8c2e8e265a71fd236917f187508f3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 3 Mar 2001 05:11:06 +0000 Subject: [PATCH 12/37] Put all implementation into namespace boost::detail::iterator_traits_. Some progress made on fixes for Intel compiler. [SVN r9389] --- include/boost/detail/iterator.hpp | 41 +++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index af238af..9f71a24 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -28,6 +28,9 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 03 Mar 2001 - Put all implementation into namespace +// boost::detail::iterator_traits_. Some progress made on fixes +// for Intel compiler. (David Abrahams) // 02 Mar 2001 - Changed BOOST_MSVC to BOOST_MSVC_STD_ITERATOR in a few // places. (Jeremy Siek) // 19 Feb 2001 - Improved workarounds for stock MSVC6; use yes_type and @@ -58,7 +61,7 @@ # include # include -# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +# if defined(BOOST_MSVC_STD_ITERATOR) # include # include # include @@ -88,6 +91,8 @@ using std::iterator_traits; using std::distance; # else +namespace iterator_traits_ { + // Workarounds for less-capable implementations template struct iterator_traits_select; @@ -111,7 +116,11 @@ template <> struct iterator_traits_select }; +typedef char yes_type; +typedef double no_type; + # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF + no_type bad_category_helper(...); template yes_type bad_category_helper(std::_DBG_iter*); @@ -245,11 +254,11 @@ no_type is_boost_iterator_helper(...); // Is the iterator one of the known mutable container iterators? template -yes_type is_mutable_iterator_helper(const volatile std::_Tree::iterator*); +yes_type is_mutable_iterator_helper(const volatile typename std::_Tree::iterator*); template -yes_type is_mutable_iterator_helper(const volatile std::list::iterator*); +yes_type is_mutable_iterator_helper(const volatile typename std::list::iterator*); template -yes_type is_mutable_iterator_helper(const volatile std::deque::iterator*); +yes_type is_mutable_iterator_helper(const volatile typename std::deque::iterator*); no_type is_mutable_iterator_helper(...); // Is the iterator an ostream_iterator? @@ -257,9 +266,15 @@ template yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator*); no_type is_ostream_iterator_helper(...); +#ifdef __ICL +template struct check; +template <> struct check {}; +check<(sizeof(is_std_iterator_helper((std::istream_iterator*)0)) == sizeof(yes_type))> assertion; +#endif + template struct msvc_iterator_classification { - enum { + BOOST_STATIC_CONSTANT(unsigned, value = (sizeof(is_ostream_iterator_helper((T*)0)) == sizeof(yes_type)) ? msvc_stdlib_ostream_iterator : (sizeof(is_mutable_iterator_helper((T*)0)) == sizeof(yes_type)) @@ -268,7 +283,7 @@ struct msvc_iterator_classification { && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_type)) ? msvc_stdlib_const_iterator : not_msvc_stdlib_iterator - }; + ); }; # endif @@ -313,12 +328,14 @@ template <> struct iterator_traits_select }; }; +} // namespace boost::detail::iterator_traits_ + template struct iterator_traits - : iterator_traits_select::value>::template traits + : iterator_traits_::iterator_traits_select::value>::template traits { private: - typedef typename iterator_traits_select< + typedef typename iterator_traits_::iterator_traits_select< is_pointer::type>::value>::template traits traits; public: // Why do I need to define these typedefs? It keeps MSVC happy somehow. @@ -327,6 +344,8 @@ struct iterator_traits typedef typename traits::iterator_category iterator_category; }; +namespace iterator_traits_ { + template struct distance_select { template @@ -353,16 +372,18 @@ struct distance_select { } }; +} // namespace boost::detail::iterator_traits_ + template inline typename ::boost::detail::iterator_traits::difference_type distance(const Iterator& first, const Iterator& last) { typedef typename ::boost::detail::iterator_traits::iterator_category iterator_category; - return distance_select::distance(first, last); + return iterator_traits_::distance_select::distance(first, last); } # endif // workarounds -}} +}} // namespace boost::detail # undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION From b516c62f1ed8282d782a10d99547abd9fa7c0e34 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:08:17 +0000 Subject: [PATCH 13/37] More attempted fixes for Intel C++ [SVN r9406] --- include/boost/detail/iterator.hpp | 50 +++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 9f71a24..d97bfd7 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -28,6 +28,7 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 04 Mar 2001 - More attempted fixes for Intel C++ (David Abrahams) // 03 Mar 2001 - Put all implementation into namespace // boost::detail::iterator_traits_. Some progress made on fixes // for Intel compiler. (David Abrahams) @@ -65,6 +66,10 @@ # include # include # include +# if 0 && defined(__ICL) // Re-enable this to pick up the Intel fixes where they left off +# include +# include +# endif # endif @@ -86,7 +91,7 @@ # endif // STLPort <= 4.1b4 && no partial specialization namespace boost { namespace detail { -# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) using std::iterator_traits; using std::distance; # else @@ -243,9 +248,45 @@ template <> struct msvc_traits_select // falls into. // Is the iterator derived from std::iterator? +no_type is_std_iterator_helper(...); template yes_type is_std_iterator_helper(const volatile std::iterator*); -no_type is_std_iterator_helper(...); + +#if 0 && defined(__ICL) // re-enable this to pick up with the Intel C++ fixes where they left off +// for some reason, it's unable to make the deduction of derivation :( +template +yes_type is_std_iterator_helper(const volatile typename std::_Tree::iterator*); +template +yes_type is_std_iterator_helper(const volatile typename std::list::iterator*); +template +yes_type is_std_iterator_helper(const volatile typename std::deque::iterator*); + +template +yes_type is_std_iterator_helper(const volatile typename std::_Tree::const_iterator*); +template +yes_type is_std_iterator_helper(const volatile typename std::list::const_iterator*); +template +yes_type is_std_iterator_helper(const volatile typename std::deque::const_iterator*); + +template +yes_type is_std_iterator_helper(const volatile std::reverse_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::reverse_bidirectional_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::back_insert_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::front_insert_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::insert_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::istream_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::istreambuf_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::ostreambuf_iterator*); +template +yes_type is_std_iterator_helper(const volatile std::raw_storage_iterator*); +#endif // Is the iterator derived from boost::iterator? template @@ -266,7 +307,10 @@ template yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator*); no_type is_ostream_iterator_helper(...); -#ifdef __ICL +#if 0 && defined(__ICL) +// this static assertion highlights the first of a few problems getting this to +// work with the Intel compiler. We can get past it with the many definitions +// for is_std_iterator_helper above, but there are other failures. template struct check; template <> struct check {}; check<(sizeof(is_std_iterator_helper((std::istream_iterator*)0)) == sizeof(yes_type))> assertion; From 6d43d2e762b404a17a132cf68d419b106f3a73bd Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Thu, 12 Jul 2001 17:40:38 +0000 Subject: [PATCH 14/37] fix duplicate typedef [SVN r10597] --- include/boost/detail/iterator.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index d97bfd7..158bcd1 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -348,7 +348,6 @@ template <> struct iterator_traits_select # elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; - typedef typename Iterator::difference_type difference_type; typedef typename Iterator::pointer pointer; typedef typename Iterator::reference reference; # else From 8a2d97e68656e99f49f8889b917f365ca3a3e7b1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 19 Jan 2002 02:21:24 +0000 Subject: [PATCH 15/37] Cleared out bogus flotsam [SVN r12350] --- include/boost/detail/iterator.hpp | 45 ------------------------------- 1 file changed, 45 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 158bcd1..c485a4d 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -252,42 +252,6 @@ no_type is_std_iterator_helper(...); template yes_type is_std_iterator_helper(const volatile std::iterator*); -#if 0 && defined(__ICL) // re-enable this to pick up with the Intel C++ fixes where they left off -// for some reason, it's unable to make the deduction of derivation :( -template -yes_type is_std_iterator_helper(const volatile typename std::_Tree::iterator*); -template -yes_type is_std_iterator_helper(const volatile typename std::list::iterator*); -template -yes_type is_std_iterator_helper(const volatile typename std::deque::iterator*); - -template -yes_type is_std_iterator_helper(const volatile typename std::_Tree::const_iterator*); -template -yes_type is_std_iterator_helper(const volatile typename std::list::const_iterator*); -template -yes_type is_std_iterator_helper(const volatile typename std::deque::const_iterator*); - -template -yes_type is_std_iterator_helper(const volatile std::reverse_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::reverse_bidirectional_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::back_insert_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::front_insert_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::insert_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::istream_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::istreambuf_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::ostreambuf_iterator*); -template -yes_type is_std_iterator_helper(const volatile std::raw_storage_iterator*); -#endif - // Is the iterator derived from boost::iterator? template yes_type is_boost_iterator_helper(const volatile boost::iterator*); @@ -307,15 +271,6 @@ template yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator*); no_type is_ostream_iterator_helper(...); -#if 0 && defined(__ICL) -// this static assertion highlights the first of a few problems getting this to -// work with the Intel compiler. We can get past it with the many definitions -// for is_std_iterator_helper above, but there are other failures. -template struct check; -template <> struct check {}; -check<(sizeof(is_std_iterator_helper((std::istream_iterator*)0)) == sizeof(yes_type))> assertion; -#endif - template struct msvc_iterator_classification { BOOST_STATIC_CONSTANT(unsigned, From 90df347b2340a92770f95c638e77914bf792f241 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 28 May 2002 20:25:51 +0000 Subject: [PATCH 16/37] Workaround BOOST_MSVC_STD_ITERATOR misconfiguration; add MSVC6 specificity [SVN r14047] --- include/boost/detail/iterator.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index c485a4d..9833146 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -62,14 +62,10 @@ # include # include -# if defined(BOOST_MSVC_STD_ITERATOR) +# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT) # include # include # include -# if 0 && defined(__ICL) // Re-enable this to pick up the Intel fixes where they left off -# include -# include -# endif # endif @@ -110,7 +106,7 @@ template <> struct iterator_traits_select typedef std::ptrdiff_t difference_type; typedef std::random_access_iterator_tag iterator_category; typedef Ptr pointer; -#ifdef BOOST_MSVC +#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // Keeps MSVC happy under certain circumstances. It seems class template default // arguments are partly instantiated even when not used when the class template // is the return type of a function template. @@ -183,7 +179,7 @@ struct bad_output_iterator_select }; # endif -# if defined(BOOST_MSVC_STD_ITERATOR) +# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT) // We'll sort iterator types into one of these classifications, from which we // can determine the difference_type, pointer, reference, and value_type @@ -291,7 +287,7 @@ template <> struct iterator_traits_select template struct traits { -# if defined(BOOST_MSVC_STD_ITERATOR) +# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT) typedef msvc_traits_select<( msvc_iterator_classification::value )>::template traits_ inner_traits; From 5abb2a78dc7343512caa9e52dd6f1d6b1bc97512 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 8 Nov 2002 06:57:31 +0000 Subject: [PATCH 17/37] Cleanups on boost::iterator_traits<> Broke MSVC though :( [SVN r16157] --- include/boost/detail/iterator.hpp | 452 ++++++++++++++---------------- 1 file changed, 209 insertions(+), 243 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 9833146..83e138a 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -1,4 +1,4 @@ -// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, +// (C) Copyright David Abrahams 2002. Permission to copy, use, modify, // sell and distribute this software is granted provided this // copyright notice appears in all copies. This software is provided // "as is" without express or implied warranty, and with no claim as @@ -20,11 +20,6 @@ // std::iterator_traits::pointer // std::iterator_traits::reference // -// CAVEAT: When using the VC6 standard library, an iterator derived from -// std::iterator but not boost::iterator or from one supplied by the standard -// will always have pointer == const value_type* and reference == const -// value_type&, whether that's correct or not. - // See http://www.boost.org for most recent version including documentation. // Revision History @@ -57,17 +52,17 @@ # define ITERATOR_DWA122600_HPP_ # include -# include -# include +# include +# include +# include +# include +# include +# include # include # include -# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT) -# include -# include -# include -# endif - +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" // STLPort 4.0 and betas have a bug when debugging is enabled and there is no // partial specialization: instead of an iterator_category typedef, the standard @@ -76,9 +71,9 @@ // Also, whether debugging is enabled or not, there is a broken specialization // of std::iterator which has no // typedefs but iterator_category. -# if defined(__SGI_STL_PORT) && (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) +# if defined(__SGI_STL_PORT) -# ifdef __STL_DEBUG +# if (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && defined(__STL_DEBUG) # define BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # endif @@ -87,293 +82,264 @@ # endif // STLPort <= 4.1b4 && no partial specialization namespace boost { namespace detail { + # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) using std::iterator_traits; using std::distance; # else -namespace iterator_traits_ { +// is_mutable_iterator -- +// +// A metafunction returning true iff T is a mutable iterator +// type with a nested value_type. -// Workarounds for less-capable implementations -template struct iterator_traits_select; +// This one detects ordinary mutable iterators - the result of +// operator* is convertible to the value_type. +template +type_traits::yes_type is_mutable_iterator_helper(T const*, BOOST_DEDUCED_TYPENAME T::value_type*); -template struct undefined; -template <> struct iterator_traits_select +// This one detects output iterators such as ostream_iterator which +// return references to themselves. +template +type_traits::yes_type is_mutable_iterator_helper(T const*, T const*); + +type_traits::no_type is_mutable_iterator_helper(...); + +template +struct is_mutable_iterator_impl { - template - struct traits - { - typedef std::ptrdiff_t difference_type; - typedef std::random_access_iterator_tag iterator_category; - typedef Ptr pointer; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 -// Keeps MSVC happy under certain circumstances. It seems class template default -// arguments are partly instantiated even when not used when the class template -// is the return type of a function template. - typedef undefined value_type; - typedef undefined reference; -#endif - }; + static T t; + + BOOST_STATIC_CONSTANT(bool, value = sizeof( + detail::is_mutable_iterator_helper((T*)0, &*t)) + == sizeof(type_traits::yes_type) + ); }; +BOOST_TT_AUX_BOOL_TRAIT_DEF1( + is_mutable_iterator,T,::boost::detail::is_mutable_iterator_impl::value) -typedef char yes_type; -typedef double no_type; -# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +// is_full_iterator_traits -- +// +// A metafunction returning true iff T has all the requisite nested +// types to satisfy the requirements for a fully-conforming +// iterator_traits implementation. +template +type_traits::yes_type is_full_iterator_traits_helper( + T const volatile* + , BOOST_DEDUCED_TYPENAME T::value_type* = 0 + , BOOST_DEDUCED_TYPENAME T::reference (*)() = 0 + , BOOST_DEDUCED_TYPENAME T::pointer* = 0 + , BOOST_DEDUCED_TYPENAME T::difference_type* = 0 + , BOOST_DEDUCED_TYPENAME T::iterator_category* = 0 + ); -no_type bad_category_helper(...); -template yes_type bad_category_helper(std::_DBG_iter*); +type_traits::no_type is_full_iterator_traits_helper(...); -template struct bad_category_select; -template <> -struct bad_category_select +template +struct is_full_iterator_traits_impl { - template - struct category { typedef typename Iterator::_Iterator_category type; }; -}; -template <> -struct bad_category_select -{ - template - struct category { typedef typename Iterator::iterator_category type; }; + enum { value = sizeof( + is_full_iterator_traits_helper((T*)0)) == sizeof(type_traits::yes_type) }; }; -template -struct iterator_category_select +BOOST_TT_AUX_BOOL_TRAIT_DEF1( + is_full_iterator_traits,T,::boost::detail::is_full_iterator_traits_impl::value) + + +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +// is_stlport_40_debug_iterator -- +// +// A metafunction returning true iff T has all the requisite nested +// types to satisfy the requirements of an STLPort 4.0 debug iterator +// iterator_traits implementation. +template +type_traits::yes_type is_stlport_40_debug_iterator_helper( + T const volatile* + , BOOST_DEDUCED_TYPENAME T::value_type* = 0 + , BOOST_DEDUCED_TYPENAME T::reference (*)() = 0 + , BOOST_DEDUCED_TYPENAME T::pointer* = 0 + , BOOST_DEDUCED_TYPENAME T::difference_type* = 0 + , BOOST_DEDUCED_TYPENAME T::_Iterator_category* = 0 + ); + +type_traits::no_type is_stlport_40_debug_iterator_helper(...); + +template +struct is_stlport_40_debug_iterator_impl { - private: - static Iterator p; - enum { has_bad_category - = sizeof(bad_category_helper(&p)) == sizeof(yes_type) }; - typedef bad_category_select category_select; - public: - typedef typename category_select::template category::type type; + enum { value = sizeof( + is_stlport_40_debug_iterator_helper((T*)0)) == sizeof(type_traits::yes_type) }; }; -# endif +BOOST_TT_AUX_BOOL_TRAIT_DEF1( + is_stlport_40_debug_iterator,T,::boost::detail::is_stlport_40_debug_iterator_impl::value) -# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION -template struct bad_output_iterator_select; -template <> -struct bad_output_iterator_select +template +struct stlport_40_debug_iterator_traits { - template - struct non_category_traits { - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - }; + typedef typename T::value_type value_type; + typedef typename T::reference reference; + typedef typename T::pointer pointer; + typedef typename T::difference_type difference_type; + typedef typename T::_Iterator_category iterator_category; }; -template <> -struct bad_output_iterator_select +# endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF + +template +struct pointer_iterator_traits { - template - struct non_category_traits { - typedef typename Iterator::value_type value_type; - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; - }; + typedef T pointer; + typedef std::random_access_iterator_tag iterator_category; + typedef std::ptrdiff_t difference_type; +}; + +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct pointer_iterator_traits +{ + typedef remove_const::type value_type; + typedef T* pointer; + typedef T& reference; + typedef std::random_access_iterator_tag iterator_category; + typedef std::ptrdiff_t difference_type; }; # endif -# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT) - // We'll sort iterator types into one of these classifications, from which we // can determine the difference_type, pointer, reference, and value_type -enum { - not_msvc_stdlib_iterator, - msvc_stdlib_const_iterator, - msvc_stdlib_mutable_iterator, - msvc_stdlib_ostream_iterator -}; - -template struct msvc_traits_select; - -template <> struct msvc_traits_select +template +struct standard_iterator_traits { - template - struct traits_ // calling this "traits" will confuse VC. - { - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; - }; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + typedef typename Iterator::iterator_category iterator_category; }; -template <> struct msvc_traits_select +template +struct msvc_stdlib_mutable_traits + : std::iterator_traits { - template - struct traits_ - { - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; - typedef value_type* pointer; - typedef value_type& reference; - }; + typedef typename std::iterator_traits::distance_type difference_type; + typedef value_type* pointer; + typedef value_type& reference; }; -template <> struct msvc_traits_select +template +struct msvc_stdlib_const_traits + : std::iterator_traits { - template - struct traits_ - { - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; - typedef const value_type* pointer; - typedef const value_type& reference; - }; + typedef typename std::iterator_traits::distance_type difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; }; -template <> struct msvc_traits_select +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION +template +struct is_bad_output_iterator + : is_base_and_derived< + std::iterator + , Iterator> { - template - struct traits_ - { - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; - typedef void pointer; - typedef void reference; - }; }; -// These functions allow us to detect which classification a given iterator type -// falls into. - -// Is the iterator derived from std::iterator? -no_type is_std_iterator_helper(...); -template -yes_type is_std_iterator_helper(const volatile std::iterator*); - -// Is the iterator derived from boost::iterator? -template -yes_type is_boost_iterator_helper(const volatile boost::iterator*); -no_type is_boost_iterator_helper(...); - -// Is the iterator one of the known mutable container iterators? -template -yes_type is_mutable_iterator_helper(const volatile typename std::_Tree::iterator*); -template -yes_type is_mutable_iterator_helper(const volatile typename std::list::iterator*); -template -yes_type is_mutable_iterator_helper(const volatile typename std::deque::iterator*); -no_type is_mutable_iterator_helper(...); - -// Is the iterator an ostream_iterator? -template -yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator*); -no_type is_ostream_iterator_helper(...); - -template -struct msvc_iterator_classification { - BOOST_STATIC_CONSTANT(unsigned, - value = (sizeof(is_ostream_iterator_helper((T*)0)) == sizeof(yes_type)) - ? msvc_stdlib_ostream_iterator - : (sizeof(is_mutable_iterator_helper((T*)0)) == sizeof(yes_type)) - ? msvc_stdlib_mutable_iterator - : (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_type) - && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_type)) - ? msvc_stdlib_const_iterator - : not_msvc_stdlib_iterator - ); +struct bad_output_iterator_traits +{ + typedef void value_type; + typedef void difference_type; + typedef std::output_iterator_tag iterator_category; + typedef void pointer; + typedef void reference; }; # endif -template <> struct iterator_traits_select +template +struct non_pointer_iterator_traits + : mpl::if_< + is_full_iterator_traits + , standard_iterator_traits +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF + , mpl::if_< + is_stlport_40_debug_iterator + , stlport_40_debug_iterator_traits +# endif + , mpl::if_< + is_mutable_iterator + , msvc_stdlib_mutable_traits + , msvc_stdlib_const_traits + >::type +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF + >::type +# endif + >::type { - template - struct traits - { -# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT) - typedef msvc_traits_select<( - msvc_iterator_classification::value - )>::template traits_ inner_traits; - - typedef typename inner_traits::difference_type difference_type; - typedef typename inner_traits::value_type value_type; - typedef typename inner_traits::pointer pointer; - typedef typename inner_traits::reference reference; -# elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; -# else - typedef bad_output_iterator_select< - is_convertible* - >::value> non_category_traits_select; - typedef non_category_traits_select::template non_category_traits non_category_traits; - public: - typedef typename non_category_traits::value_type value_type; - typedef typename non_category_traits::difference_type difference_type; - typedef typename non_category_traits::pointer pointer; - typedef typename non_category_traits::reference reference; -# endif - -# if !defined(BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF) - typedef typename Iterator::iterator_category iterator_category; -# else - typedef typename iterator_category_select::type iterator_category; -# endif - }; }; -} // namespace boost::detail::iterator_traits_ +template +struct iterator_traits_aux + : mpl::if_< + is_pointer + , pointer_iterator_traits + , non_pointer_iterator_traits + >::type +{ +}; template struct iterator_traits - : iterator_traits_::iterator_traits_select::value>::template traits +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION + : mpl::if_< + is_bad_output_iterator + , bad_output_iterator_traits + , iterator_traits_aux + >::type +# else + : iterator_traits_aux +# endif { - private: - typedef typename iterator_traits_::iterator_traits_select< - is_pointer::type>::value>::template traits traits; - public: - // Why do I need to define these typedefs? It keeps MSVC happy somehow. - // Why don't I need to define the other typedefs? Who knows?!? - typedef typename traits::difference_type difference_type; - typedef typename traits::iterator_category iterator_category; }; -namespace iterator_traits_ { +namespace iterator_traits_ +{ + template + struct iterator_difference + { + typedef typename iterator_traits::difference_type type; + }; -template -struct distance_select { - template - static typename ::boost::detail::iterator_traits::difference_type - distance(Iterator i1, const Iterator i2) - { - typename ::boost::detail::iterator_traits::difference_type result = 0; - while (i1 != i2) - { - ++i1; - ++result; - } - return result; - } -}; - -template <> -struct distance_select { - template - static typename ::boost::detail::iterator_traits::difference_type - distance(const Iterator i1, const Iterator i2) - { - return i2 - i1; - } -}; + template + struct distance_select + { + static Difference execute(Iterator i1, const Iterator i2, ...) + { + typename Difference result = 0; + while (i1 != i2) + { + ++i1; + ++result; + } + return result; + } + static Difference execute(Iterator i1, const Iterator i2, std::random_access_iterator_tag*) + { + return i2 - i1; + } + }; } // namespace boost::detail::iterator_traits_ template -inline typename ::boost::detail::iterator_traits::difference_type -distance(const Iterator& first, const Iterator& last) +inline typename iterator_traits_::iterator_difference::type +distance(Iterator first, Iterator last) { + typedef typename iterator_traits_::iterator_difference::type diff_t; typedef typename ::boost::detail::iterator_traits::iterator_category iterator_category; - return iterator_traits_::distance_select::distance(first, last); + + return iterator_traits_::distance_select::execute( + first, last, (iterator_category*)0); } # endif // workarounds From 031625027e815a80136fae0893941c5875bfbb38 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 8 Nov 2002 17:08:17 +0000 Subject: [PATCH 18/37] Works with MSVC and Intel5 now. Thanks, Aleksey!! [SVN r16165] --- include/boost/detail/iterator.hpp | 52 ++++++++++++++----------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 83e138a..fdc0d75 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -58,9 +58,11 @@ # include # include # include +# include # include # include + // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" @@ -83,6 +85,12 @@ namespace boost { namespace detail { +BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) +BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) +BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer) +BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type) +BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) + # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) using std::iterator_traits; using std::distance; @@ -125,23 +133,16 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF1( // A metafunction returning true iff T has all the requisite nested // types to satisfy the requirements for a fully-conforming // iterator_traits implementation. -template -type_traits::yes_type is_full_iterator_traits_helper( - T const volatile* - , BOOST_DEDUCED_TYPENAME T::value_type* = 0 - , BOOST_DEDUCED_TYPENAME T::reference (*)() = 0 - , BOOST_DEDUCED_TYPENAME T::pointer* = 0 - , BOOST_DEDUCED_TYPENAME T::difference_type* = 0 - , BOOST_DEDUCED_TYPENAME T::iterator_category* = 0 - ); - -type_traits::no_type is_full_iterator_traits_helper(...); - template struct is_full_iterator_traits_impl { - enum { value = sizeof( - is_full_iterator_traits_helper((T*)0)) == sizeof(type_traits::yes_type) }; + enum { value = + has_value_type::value + & has_reference::value + & has_pointer::value + & has_difference_type::value + & has_iterator_category::value + }; }; BOOST_TT_AUX_BOOL_TRAIT_DEF1( @@ -149,28 +150,23 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF1( # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +BOOST_MPL_HAS_XXX_TRAIT_DEF(_Iterator_category) + // is_stlport_40_debug_iterator -- // // A metafunction returning true iff T has all the requisite nested // types to satisfy the requirements of an STLPort 4.0 debug iterator // iterator_traits implementation. -template -type_traits::yes_type is_stlport_40_debug_iterator_helper( - T const volatile* - , BOOST_DEDUCED_TYPENAME T::value_type* = 0 - , BOOST_DEDUCED_TYPENAME T::reference (*)() = 0 - , BOOST_DEDUCED_TYPENAME T::pointer* = 0 - , BOOST_DEDUCED_TYPENAME T::difference_type* = 0 - , BOOST_DEDUCED_TYPENAME T::_Iterator_category* = 0 - ); - -type_traits::no_type is_stlport_40_debug_iterator_helper(...); - template struct is_stlport_40_debug_iterator_impl { - enum { value = sizeof( - is_stlport_40_debug_iterator_helper((T*)0)) == sizeof(type_traits::yes_type) }; + enum { value = + has_value_type::value + & has_reference::value + & has_pointer::value + & has_difference_type::value + & has__Iterator_category::value + }; }; BOOST_TT_AUX_BOOL_TRAIT_DEF1( From bd911da83b7a91cc1a8a3cb4a5a285dba4bdaefe Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 8 Nov 2002 17:23:06 +0000 Subject: [PATCH 19/37] Final patches for MSVC6 [SVN r16166] --- include/boost/detail/iterator.hpp | 36 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index fdc0d75..33b7743 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -61,7 +61,7 @@ # include # include # include - +# include // for noncopyable // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" @@ -189,6 +189,10 @@ struct pointer_iterator_traits typedef T pointer; typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; + + // Makes MSVC6 happy under some circumstances + typedef noncopyable value_type; + typedef noncopyable reference; }; # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION @@ -286,26 +290,30 @@ struct iterator_traits_aux template struct iterator_traits +{ + // Explicit forwarding from base class needed to keep MSVC6 happy + // under some circumstances. + private: # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION - : mpl::if_< + typedef + typename mpl::if_< is_bad_output_iterator , bad_output_iterator_traits , iterator_traits_aux - >::type + >::type base; # else - : iterator_traits_aux -# endif -{ + typedef iterator_traits_aux base; +# endif + public: + typedef typename base::value_type value_type; + typedef typename base::pointer pointer; + typedef typename base::reference reference; + typedef typename base::difference_type difference_type; + typedef typename base::iterator_category iterator_category; }; namespace iterator_traits_ { - template - struct iterator_difference - { - typedef typename iterator_traits::difference_type type; - }; - template struct distance_select { @@ -328,10 +336,10 @@ namespace iterator_traits_ } // namespace boost::detail::iterator_traits_ template -inline typename iterator_traits_::iterator_difference::type +inline typename iterator_traits::difference_type distance(Iterator first, Iterator last) { - typedef typename iterator_traits_::iterator_difference::type diff_t; + typedef typename iterator_traits::difference_type diff_t; typedef typename ::boost::detail::iterator_traits::iterator_category iterator_category; return iterator_traits_::distance_select::execute( From 60a7048e986a27fdff1966690ac333a11e239abb Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 9 Nov 2002 02:37:54 +0000 Subject: [PATCH 20/37] More fixes, better error messages, etc. [SVN r16170] --- include/boost/detail/iterator.hpp | 90 ++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 33b7743..5bd470e 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -52,8 +52,6 @@ # define ITERATOR_DWA122600_HPP_ # include -# include -# include # include # include # include @@ -61,7 +59,6 @@ # include # include # include -# include // for noncopyable // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" @@ -91,15 +88,25 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer) BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type) BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) -# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) -using std::iterator_traits; +# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \ + && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_MSVC_STD_ITERATOR) +// Define a new template so it can be specialized +template +struct iterator_traits + : std::iterator_traits +{}; using std::distance; # else // is_mutable_iterator -- // -// A metafunction returning true iff T is a mutable iterator -// type with a nested value_type. +// A metafunction returning true iff T is a mutable iterator type +// with a nested value_type. Will only work portably with iterators +// whose operator* returns a reference, but that seems to be OK for +// the iterators supplied by Dinkumware. Some input iterators may +// compile-time if they arrive here, and if the compiler is strict +// about not taking the address of an rvalue. // This one detects ordinary mutable iterators - the result of // operator* is convertible to the value_type. @@ -182,18 +189,8 @@ struct stlport_40_debug_iterator_traits typedef typename T::_Iterator_category iterator_category; }; # endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF - -template -struct pointer_iterator_traits -{ - typedef T pointer; - typedef std::random_access_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - // Makes MSVC6 happy under some circumstances - typedef noncopyable value_type; - typedef noncopyable reference; -}; +template struct pointer_iterator_traits; # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template @@ -205,7 +202,36 @@ struct pointer_iterator_traits typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; }; -# endif +# else +template +struct must_manually_specialize_boost_detail_iterator_traits; + +template +struct pointer_iterator_traits +{ + typedef T pointer; + typedef std::random_access_iterator_tag iterator_category; + typedef std::ptrdiff_t difference_type; + + // Makes MSVC6 happy under some circumstances + typedef must_manually_specialize_boost_detail_iterator_traits value_type; + typedef must_manually_specialize_boost_detail_iterator_traits reference; +}; + +// Use this as a base class in manual iterator_traits specializations +// for pointer types. T should be the value_type. CV should be the +// cv-qualified value_type to which */& is added in order to produce +// pointer/reference. +template +struct ptr_iter_traits +{ + typedef T value_type; + typedef CV* pointer; + typedef CV& reference; + typedef std::random_access_iterator_tag iterator_category; + typedef std::ptrdiff_t difference_type; +}; +# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // We'll sort iterator types into one of these classifications, from which we // can determine the difference_type, pointer, reference, and value_type @@ -256,21 +282,32 @@ struct bad_output_iterator_traits }; # endif +// If we're looking at an MSVC6 (old Dinkumware) ``standard'' +// iterator, this will generate an appropriate traits class. +template +struct msvc_stdlib_iterator_traits + : mpl::if_< + is_mutable_iterator + , msvc_stdlib_mutable_traits + , msvc_stdlib_const_traits + >::type +{}; + template struct non_pointer_iterator_traits : mpl::if_< + // if the iterator contains all the right nested types... is_full_iterator_traits + // Use a standard iterator_traits implementation , standard_iterator_traits # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF + // Check for STLPort 4.0 broken _Iterator_category type , mpl::if_< is_stlport_40_debug_iterator , stlport_40_debug_iterator_traits -# endif - , mpl::if_< - is_mutable_iterator - , msvc_stdlib_mutable_traits - , msvc_stdlib_const_traits - >::type +# endif + // Otherwise, assume it's a Dinkum iterator + , msvc_stdlib_iterator_traits # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF >::type # endif @@ -312,6 +349,9 @@ struct iterator_traits typedef typename base::iterator_category iterator_category; }; +// This specialization cuts off ETI (Early Template Instantiation) for MSVC. +template <> struct iterator_traits{}; + namespace iterator_traits_ { template From 1d5a04b63783109b8a1e4e2ce244d49e6c21fdc1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 9 Nov 2002 02:39:38 +0000 Subject: [PATCH 21/37] add missing #include [SVN r16171] --- include/boost/detail/iterator.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 5bd470e..9654add 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -56,6 +56,7 @@ # include # include # include +# include # include # include # include From fe5130cc1f851cc5cd8a6a2d15ea25a7fa842ac3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 4 Dec 2002 15:52:33 +0000 Subject: [PATCH 22/37] Workarounds for broken RogueWave lib that comes with Sun [SVN r16509] --- include/boost/detail/iterator.hpp | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 9654add..40bfd41 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -98,6 +98,42 @@ struct iterator_traits : std::iterator_traits {}; using std::distance; +# elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_MSVC_STD_ITERATOR) + +// Rogue Wave Standard Library fools itself into thinking partial +// specialization is missing on some platforms (e.g. Sun), so fails to +// supply iterator_traits! +template +struct iterator_traits +{ + typedef typename Iterator::value_type value_type; + typedef typename Iterator::reference reference; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::iterator_category iterator_category; +}; + +template +struct iterator_traits +{ + typedef T value_type; + typedef T& reference; + typedef T* pointer; + typedef std::ptrdiff_t difference_type; + typedef std::random_access_iterator_tag iterator_category; +}; + +template +struct iterator_traits +{ + typedef T value_type; + typedef T const& reference; + typedef T const* pointer; + typedef std::ptrdiff_t difference_type; + typedef std::random_access_iterator_tag iterator_category; +}; + # else // is_mutable_iterator -- From 011b9471e5452227bee92d2fc8148837cf8869b8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 9 Apr 2003 11:57:59 +0000 Subject: [PATCH 23/37] Small changes to support new iterator adaptors in sandbox [SVN r18212] --- include/boost/detail/iterator.hpp | 43 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 40bfd41..8601fbc 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -62,7 +62,7 @@ # include // should be the last #include -#include "boost/type_traits/detail/bool_trait_def.hpp" +# include "boost/type_traits/detail/bool_trait_def.hpp" // STLPort 4.0 and betas have a bug when debugging is enabled and there is no // partial specialization: instead of an iterator_category typedef, the standard @@ -92,14 +92,19 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \ && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ && !defined(BOOST_MSVC_STD_ITERATOR) + // Define a new template so it can be specialized template struct iterator_traits : std::iterator_traits {}; using std::distance; -# elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - && !defined(BOOST_MSVC_STD_ITERATOR) + +# else +# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_MSVC_STD_ITERATOR) + +// This is the case where everything conforms except BOOST_NO_STD_ITERATOR_TRAITS // Rogue Wave Standard Library fools itself into thinking partial // specialization is missing on some platforms (e.g. Sun), so fails to @@ -134,7 +139,7 @@ struct iterator_traits typedef std::random_access_iterator_tag iterator_category; }; -# else +# else // is_mutable_iterator -- // @@ -193,7 +198,7 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF1( is_full_iterator_traits,T,::boost::detail::is_full_iterator_traits_impl::value) -# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF BOOST_MPL_HAS_XXX_TRAIT_DEF(_Iterator_category) // is_stlport_40_debug_iterator -- @@ -225,11 +230,11 @@ struct stlport_40_debug_iterator_traits typedef typename T::difference_type difference_type; typedef typename T::_Iterator_category iterator_category; }; -# endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF template struct pointer_iterator_traits; -# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct pointer_iterator_traits { @@ -239,7 +244,7 @@ struct pointer_iterator_traits typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; }; -# else +# else template struct must_manually_specialize_boost_detail_iterator_traits; @@ -268,7 +273,7 @@ struct ptr_iter_traits typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; }; -# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // We'll sort iterator types into one of these classifications, from which we // can determine the difference_type, pointer, reference, and value_type @@ -300,7 +305,7 @@ struct msvc_stdlib_const_traits typedef const value_type& reference; }; -# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION template struct is_bad_output_iterator : is_base_and_derived< @@ -317,7 +322,7 @@ struct bad_output_iterator_traits typedef void pointer; typedef void reference; }; -# endif +# endif // If we're looking at an MSVC6 (old Dinkumware) ``standard'' // iterator, this will generate an appropriate traits class. @@ -337,17 +342,17 @@ struct non_pointer_iterator_traits is_full_iterator_traits // Use a standard iterator_traits implementation , standard_iterator_traits -# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF // Check for STLPort 4.0 broken _Iterator_category type , mpl::if_< is_stlport_40_debug_iterator , stlport_40_debug_iterator_traits -# endif +# endif // Otherwise, assume it's a Dinkum iterator , msvc_stdlib_iterator_traits -# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF >::type -# endif +# endif >::type { }; @@ -368,16 +373,16 @@ struct iterator_traits // Explicit forwarding from base class needed to keep MSVC6 happy // under some circumstances. private: -# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION typedef typename mpl::if_< is_bad_output_iterator , bad_output_iterator_traits , iterator_traits_aux >::type base; -# else +# else typedef iterator_traits_aux base; -# endif +# endif public: typedef typename base::value_type value_type; typedef typename base::pointer pointer; @@ -389,6 +394,8 @@ struct iterator_traits // This specialization cuts off ETI (Early Template Instantiation) for MSVC. template <> struct iterator_traits{}; +# endif + namespace iterator_traits_ { template From e0f121df348649a46233423ba7cd31251c4fbb20 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Aug 2003 16:52:02 +0000 Subject: [PATCH 24/37] Moved to much cleaner system of using BOOST_TT_BROKEN_COMPILER_SPEC for handling vc6/7 deficiencies with iterator_traits. Fixed a bug in iterator_facade which was causing incomplete types to be passed through is_convertible. Reinstated libs/utility/iterator_traits_test.cpp [SVN r19840] --- include/boost/detail/iterator.hpp | 157 ++++++++++++++++++++++-------- 1 file changed, 117 insertions(+), 40 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 8601fbc..70d83f1 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -52,17 +52,7 @@ # define ITERATOR_DWA122600_HPP_ # include -# include -# include -# include -# include -# include -# include # include -# include - -// should be the last #include -# include "boost/type_traits/detail/bool_trait_def.hpp" // STLPort 4.0 and betas have a bug when debugging is enabled and there is no // partial specialization: instead of an iterator_category typedef, the standard @@ -81,18 +71,12 @@ # endif // STLPort <= 4.1b4 && no partial specialization -namespace boost { namespace detail { - -BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) -BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) -BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer) -BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type) -BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) - # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \ && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ && !defined(BOOST_MSVC_STD_ITERATOR) +namespace boost { namespace detail { + // Define a new template so it can be specialized template struct iterator_traits @@ -100,12 +84,17 @@ struct iterator_traits {}; using std::distance; +}} // namespace boost::detail + # else + # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ && !defined(BOOST_MSVC_STD_ITERATOR) // This is the case where everything conforms except BOOST_NO_STD_ITERATOR_TRAITS +namespace boost { namespace detail { + // Rogue Wave Standard Library fools itself into thinking partial // specialization is missing on some platforms (e.g. Sun), so fails to // supply iterator_traits! @@ -139,8 +128,48 @@ struct iterator_traits typedef std::random_access_iterator_tag iterator_category; }; +}} // namespace boost::detail + # else +# include +# include +# include + +# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# include +# include +# endif +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION +# include +# endif + +# include + +# include +# if BOOST_MSVC == 1300 +# include +# include +# endif + +# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# include +# include +# endif +# include +# include + +// should be the last #include +# include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { namespace detail { + +BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) +BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) +BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer) +BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type) +BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) + // is_mutable_iterator -- // // A metafunction returning true iff T is a mutable iterator type @@ -244,9 +273,65 @@ struct pointer_iterator_traits typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; }; -# else -template -struct must_manually_specialize_boost_detail_iterator_traits; +# else + +// In case of no template partial specialization, and if T is a +// pointer, iterator_traits::value_type can still be computed. For +// some basic types, remove_pointer is manually defined in +// type_traits/broken_compiler_spec.hpp. For others, do it yourself. + +template class please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee; + +template +struct pointer_value_type +# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) || BOOST_WORKAROUND(__EDG_VERSION__, != 0) +// Special formulation required to get +// please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee +// to show up in vc7 errors. It's better to use the other one if +// possible because it means you can use the other members of +// iterator_traits + : mpl::apply_if< + is_same::type> + , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

+ , remove_const< + typename remove_pointer

::type + > + > +# else + : mpl::if_< + is_same::type> + , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

+ , typename remove_const< + typename remove_pointer

::type + >::type + > +# endif +{ +}; + + +template +struct pointer_reference +# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) || BOOST_WORKAROUND(__EDG_VERSION__, != 0) +// Special formulation required to get +// please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee to +// show up in vc7 errors. It's better to use the other one if +// possible because it means you can use the other members of +// iterator_traits + : mpl::apply_if< + is_same::type> + , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

+ , add_reference::type> + > +# else + : mpl::if_< + is_same::type> + , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

+ , typename remove_pointer

::type& + > +# endif +{ +}; template struct pointer_iterator_traits @@ -255,24 +340,10 @@ struct pointer_iterator_traits typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; - // Makes MSVC6 happy under some circumstances - typedef must_manually_specialize_boost_detail_iterator_traits value_type; - typedef must_manually_specialize_boost_detail_iterator_traits reference; + typedef typename pointer_value_type::type value_type; + typedef typename pointer_reference::type reference; }; -// Use this as a base class in manual iterator_traits specializations -// for pointer types. T should be the value_type. CV should be the -// cv-qualified value_type to which */& is added in order to produce -// pointer/reference. -template -struct ptr_iter_traits -{ - typedef T value_type; - typedef CV* pointer; - typedef CV& reference; - typedef std::random_access_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; -}; # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // We'll sort iterator types into one of these classifications, from which we @@ -394,7 +465,11 @@ struct iterator_traits // This specialization cuts off ETI (Early Template Instantiation) for MSVC. template <> struct iterator_traits{}; -# endif +}} // namespace boost::detail + +# endif // workarounds + +namespace boost { namespace detail { namespace iterator_traits_ { @@ -429,9 +504,11 @@ distance(Iterator first, Iterator last) return iterator_traits_::distance_select::execute( first, last, (iterator_category*)0); } -# endif // workarounds -}} // namespace boost::detail +}} + +# endif + # undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION From 3c0df453c3707404471dce1268d2c1df954187c9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Aug 2003 20:18:51 +0000 Subject: [PATCH 25/37] Removed code-breaking change from boost/detail/iterator.hpp and corresponding workarounds from tests. Added permutation_iterator_test to the suite after fixing it up -- it was riddled with bugs! [SVN r19841] --- include/boost/detail/iterator.hpp | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 70d83f1..3b02804 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -284,20 +284,6 @@ template class please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqual template struct pointer_value_type -# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) || BOOST_WORKAROUND(__EDG_VERSION__, != 0) -// Special formulation required to get -// please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee -// to show up in vc7 errors. It's better to use the other one if -// possible because it means you can use the other members of -// iterator_traits - : mpl::apply_if< - is_same::type> - , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

- , remove_const< - typename remove_pointer

::type - > - > -# else : mpl::if_< is_same::type> , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

@@ -305,31 +291,17 @@ struct pointer_value_type typename remove_pointer

::type >::type > -# endif { }; template struct pointer_reference -# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) || BOOST_WORKAROUND(__EDG_VERSION__, != 0) -// Special formulation required to get -// please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee to -// show up in vc7 errors. It's better to use the other one if -// possible because it means you can use the other members of -// iterator_traits - : mpl::apply_if< - is_same::type> - , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

- , add_reference::type> - > -# else : mpl::if_< is_same::type> , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

, typename remove_pointer

::type& > -# endif { }; From a340b0ef6c516e1d93b2e81ccbf33c5c4eb0a0c7 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 29 Aug 2003 12:12:08 +0000 Subject: [PATCH 26/37] Remove flotsam #includes [SVN r19855] --- include/boost/detail/iterator.hpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 3b02804..a6f3ced 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -145,17 +145,6 @@ struct iterator_traits # endif # include - -# include -# if BOOST_MSVC == 1300 -# include -# include -# endif - -# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -# include -# include -# endif # include # include From bedeaa19fdbfa014e858a0c3c0f8a691b0a5dd46 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 4 Sep 2003 21:14:27 +0000 Subject: [PATCH 27/37] Added nested typedefs in iterator_traits for ETI cutoff [SVN r19920] --- include/boost/detail/iterator.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index a6f3ced..f528ddc 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -424,7 +424,14 @@ struct iterator_traits }; // This specialization cuts off ETI (Early Template Instantiation) for MSVC. -template <> struct iterator_traits{}; +template <> struct iterator_traits +{ + typedef int value_type; + typedef int pointer; + typedef int reference; + typedef int difference_type; + typedef int iterator_category; +}; }} // namespace boost::detail From 158efbc04686da0e406253ffe2f82245396e1cb6 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 25 Sep 2003 19:30:53 +0000 Subject: [PATCH 28/37] Bugfix from Thorsten Ottosen [SVN r20187] --- include/boost/detail/iterator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index f528ddc..4f24649 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -446,7 +446,7 @@ namespace iterator_traits_ { static Difference execute(Iterator i1, const Iterator i2, ...) { - typename Difference result = 0; + Difference result = 0; while (i1 != i2) { ++i1; From cfde71017800c91246a57f9910ba19455e1d7d97 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 2 Nov 2003 05:37:38 +0000 Subject: [PATCH 29/37] Handle non-lvalue iterators properly [SVN r20585] --- include/boost/detail/iterator.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 4f24649..5a692ee 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -173,6 +173,13 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) template type_traits::yes_type is_mutable_iterator_helper(T const*, BOOST_DEDUCED_TYPENAME T::value_type*); +// Since you can't take the address of an rvalue, the guts of +// is_mutable_iterator_impl will fail if we use &*t directly. This +// makes sure we can still work with non-lvalue iterators. +template T* mutable_iterator_lvalue_helper(T& x); +int mutable_iterator_lvalue_helper(...); + + // This one detects output iterators such as ostream_iterator which // return references to themselves. template @@ -185,10 +192,14 @@ struct is_mutable_iterator_impl { static T t; - BOOST_STATIC_CONSTANT(bool, value = sizeof( - detail::is_mutable_iterator_helper((T*)0, &*t)) - == sizeof(type_traits::yes_type) - ); + BOOST_STATIC_CONSTANT( + bool, value = sizeof( + detail::is_mutable_iterator_helper( + (T*)0 + , mutable_iterator_lvalue_helper(*t) // like &*t + )) + == sizeof(type_traits::yes_type) + ); }; BOOST_TT_AUX_BOOL_TRAIT_DEF1( From 6307b81a323ef044afcd7c211757dcf9d4651f5d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 26 Jul 2004 00:32:12 +0000 Subject: [PATCH 30/37] Converted to Boost Software License, Version 1.0 [SVN r24055] --- include/boost/detail/iterator.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 5a692ee..b04d8b8 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -1,8 +1,7 @@ -// (C) Copyright David Abrahams 2002. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. +// (C) Copyright David Abrahams 2002. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // Boost versions of // From a1677ce996ede86da07d958d7d324d522f8d9268 Mon Sep 17 00:00:00 2001 From: Stefan Slapeta Date: Thu, 5 Aug 2004 10:52:25 +0000 Subject: [PATCH 31/37] Name lookup fix for CW [SVN r24300] --- include/boost/detail/iterator.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index b04d8b8..70f6b5e 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -334,8 +334,8 @@ struct msvc_stdlib_mutable_traits : std::iterator_traits { typedef typename std::iterator_traits::distance_type difference_type; - typedef value_type* pointer; - typedef value_type& reference; + typedef typename std::iterator_traits::value_type* pointer; + typedef typename std::iterator_traits::value_type& reference; }; template @@ -343,8 +343,8 @@ struct msvc_stdlib_const_traits : std::iterator_traits { typedef typename std::iterator_traits::distance_type difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; + typedef const typename std::iterator_traits::value_type* pointer; + typedef const typename std::iterator_traits::value_type& reference; }; # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION From 9daff3f91ee8fe660f34dd1c1475121eabfc2b9b Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Thu, 2 Sep 2004 15:41:37 +0000 Subject: [PATCH 32/37] merge new MPL version from 'mplbook' branch [SVN r24874] --- include/boost/detail/iterator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 70f6b5e..78700b9 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -144,7 +144,7 @@ struct iterator_traits # endif # include -# include +# include # include // should be the last #include From d26792953134fa813131e7d8c82177feb77432d4 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 3 Sep 2004 15:41:08 +0000 Subject: [PATCH 33/37] Bug fix from Marvin H. Sielenkemper - sielenk-at-sf.net [SVN r24891] --- include/boost/detail/iterator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 78700b9..5bb9c62 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -266,7 +266,7 @@ template struct pointer_iterator_traits; template struct pointer_iterator_traits { - typedef remove_const::type value_type; + typedef typename remove_const::type value_type; typedef T* pointer; typedef T& reference; typedef std::random_access_iterator_tag iterator_category; From 4e5b2b44f8072f3423ca515f2073eabedead0283 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:13:10 +0000 Subject: [PATCH 34/37] Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Process #ifdef...#endif blocks. [SVN r86243] --- include/boost/detail/iterator.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 5bb9c62..896bb3d 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -135,10 +135,6 @@ struct iterator_traits # include # include -# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -# include -# include -# endif # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION # include # endif From becc33636534a8fb0d611673cd6354e0ae52d439 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:17:48 +0000 Subject: [PATCH 35/37] Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Process #ifndef...#else...#endif blocks. [SVN r86245] --- include/boost/detail/iterator.hpp | 45 ------------------------------- 1 file changed, 45 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 896bb3d..a43e8f9 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -258,7 +258,6 @@ struct stlport_40_debug_iterator_traits template struct pointer_iterator_traits; -# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct pointer_iterator_traits { @@ -268,50 +267,6 @@ struct pointer_iterator_traits typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; }; -# else - -// In case of no template partial specialization, and if T is a -// pointer, iterator_traits::value_type can still be computed. For -// some basic types, remove_pointer is manually defined in -// type_traits/broken_compiler_spec.hpp. For others, do it yourself. - -template class please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee; - -template -struct pointer_value_type - : mpl::if_< - is_same::type> - , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

- , typename remove_const< - typename remove_pointer

::type - >::type - > -{ -}; - - -template -struct pointer_reference - : mpl::if_< - is_same::type> - , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee

- , typename remove_pointer

::type& - > -{ -}; - -template -struct pointer_iterator_traits -{ - typedef T pointer; - typedef std::random_access_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - - typedef typename pointer_value_type::type value_type; - typedef typename pointer_reference::type reference; -}; - -# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // We'll sort iterator types into one of these classifications, from which we // can determine the difference_type, pointer, reference, and value_type From 425a471ee37acd462c1ffee2c6a87f511671bb48 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:20:59 +0000 Subject: [PATCH 36/37] Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION [SVN r86248] --- include/boost/detail/iterator.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index a43e8f9..9260c0b 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -71,7 +71,6 @@ # endif // STLPort <= 4.1b4 && no partial specialization # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \ - && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ && !defined(BOOST_MSVC_STD_ITERATOR) namespace boost { namespace detail { From f8155d6c69d90c4becbec066f7117ae661bcc91f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:22:36 +0000 Subject: [PATCH 37/37] Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION These evaded scripting. [SVN r86249] --- include/boost/detail/iterator.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 9260c0b..abaee26 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -86,8 +86,7 @@ using std::distance; # else -# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - && !defined(BOOST_MSVC_STD_ITERATOR) +# if !defined(BOOST_MSVC_STD_ITERATOR) // This is the case where everything conforms except BOOST_NO_STD_ITERATOR_TRAITS