From 6e06e4f89e4090ec63fa76489049580c59e7bba2 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 19 Nov 2003 20:16:52 +0000 Subject: [PATCH] Refactored minimum_category [SVN r20865] --- .../iterator/detail/minimum_category.hpp | 90 +++++++++++++++++++ .../boost/iterator/iterator_categories.hpp | 80 +---------------- include/boost/iterator/zip_iterator.hpp | 2 + 3 files changed, 93 insertions(+), 79 deletions(-) create mode 100755 include/boost/iterator/detail/minimum_category.hpp diff --git a/include/boost/iterator/detail/minimum_category.hpp b/include/boost/iterator/detail/minimum_category.hpp new file mode 100755 index 0000000..bb323f1 --- /dev/null +++ b/include/boost/iterator/detail/minimum_category.hpp @@ -0,0 +1,90 @@ +// Copyright David Abrahams 2003. Use, modification and distribution is +// subject to 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) +#ifndef MINIMUM_CATEGORY_DWA20031119_HPP +# define MINIMUM_CATEGORY_DWA20031119_HPP + +# include +# include + +# include + +namespace boost { namespace detail { +// +// Returns the minimum category type or error_type +// if T1 and T2 are unrelated. +// +// For compilers not supporting is_convertible this only +// works with the new boost return and traversal category +// types. The exact boost _types_ are required. No derived types +// will work. +// +// +template +struct minimum_category_impl; + +template +struct error_not_related_by_convertibility; + +template <> +struct minimum_category_impl +{ + template struct apply + { + typedef T2 type; + }; +}; + +template <> +struct minimum_category_impl +{ + template struct apply + { + typedef T1 type; + }; +}; + +template <> +struct minimum_category_impl +{ + template struct apply + { + BOOST_STATIC_ASSERT((is_same::value)); + typedef T1 type; + }; +}; + +template <> +struct minimum_category_impl +{ + template struct apply + : error_not_related_by_convertibility + { + }; +}; + +template +struct minimum_category +{ + typedef minimum_category_impl< + ::boost::is_convertible::value + , ::boost::is_convertible::value + > outer; + + typedef typename outer::template apply inner; + typedef typename inner::type type; + + BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2)) + }; + +# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) +template <> +struct minimum_category +{ + typedef int type; +}; +# endif + +}} // namespace boost::detail + +#endif // MINIMUM_CATEGORY_DWA20031119_HPP diff --git a/include/boost/iterator/iterator_categories.hpp b/include/boost/iterator/iterator_categories.hpp index cf5ac39..5da1956 100644 --- a/include/boost/iterator/iterator_categories.hpp +++ b/include/boost/iterator/iterator_categories.hpp @@ -17,10 +17,8 @@ # include # include # include -# include # include -# include # include @@ -44,83 +42,7 @@ struct random_access_traversal_tag : bidirectional_traversal_tag {}; namespace detail -{ - - // - // Returns the minimum category type or error_type - // if T1 and T2 are unrelated. - // - // For compilers not supporting is_convertible this only - // works with the new boost return and traversal category - // types. The exact boost _types_ are required. No derived types - // will work. - // - // - template - struct minimum_category_impl; - - template - struct error_not_related_by_convertibility; - - template <> - struct minimum_category_impl - { - template struct apply - { - typedef T2 type; - }; - }; - - template <> - struct minimum_category_impl - { - template struct apply - { - typedef T1 type; - }; - }; - - template <> - struct minimum_category_impl - { - template struct apply - { - BOOST_STATIC_ASSERT((is_same::value)); - typedef T1 type; - }; - }; - - template <> - struct minimum_category_impl - { - template struct apply - : error_not_related_by_convertibility - { - }; - }; - - template - struct minimum_category - { - typedef minimum_category_impl< - ::boost::is_convertible::value - , ::boost::is_convertible::value - > outer; - - typedef typename outer::template apply inner; - typedef inner::type type; - - BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2)) - }; - -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - template <> - struct minimum_category - { - typedef int type; - }; -# endif - +{ // // Convert a "strictly old-style" iterator category to a traversal // tag. This is broken out into a separate metafunction to reduce diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index 8d60894..5b52683 100755 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -28,6 +28,8 @@ #include #include +#include + #include #if BOOST_WORKAROUND(__GNUC__, == 2) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)