Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:55

0001 // Copyright David Abrahams 2003. Use, modification and distribution is
0002 // subject to the Boost Software License, Version 1.0. (See accompanying
0003 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0004 #ifndef BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
0005 # define BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_
0006 
0007 # include <boost/static_assert.hpp>
0008 # include <boost/type_traits/is_convertible.hpp>
0009 # include <boost/type_traits/is_same.hpp>
0010 
0011 # include <boost/mpl/placeholders.hpp>
0012 # include <boost/mpl/aux_/lambda_support.hpp>
0013 
0014 namespace boost {
0015 namespace iterators {
0016 namespace detail {
0017 
0018 template <bool GreaterEqual, bool LessEqual>
0019 struct minimum_category_impl;
0020 
0021 template <class T1, class T2>
0022 struct error_not_related_by_convertibility;
0023 
0024 template <>
0025 struct minimum_category_impl<true,false>
0026 {
0027     template <class T1, class T2> struct apply
0028     {
0029         typedef T2 type;
0030     };
0031 };
0032 
0033 template <>
0034 struct minimum_category_impl<false,true>
0035 {
0036     template <class T1, class T2> struct apply
0037     {
0038         typedef T1 type;
0039     };
0040 };
0041 
0042 template <>
0043 struct minimum_category_impl<true,true>
0044 {
0045     template <class T1, class T2> struct apply
0046     {
0047         BOOST_STATIC_ASSERT((is_same<T1,T2>::value));
0048         typedef T1 type;
0049     };
0050 };
0051 
0052 template <>
0053 struct minimum_category_impl<false,false>
0054 {
0055     template <class T1, class T2> struct apply
0056       : error_not_related_by_convertibility<T1,T2>
0057     {
0058     };
0059 };
0060 
0061 } // namespace detail
0062 
0063 //
0064 // Returns the minimum category type or fails to compile
0065 // if T1 and T2 are unrelated.
0066 //
0067 template <class T1 = mpl::_1, class T2 = mpl::_2>
0068 struct minimum_category
0069 {
0070     typedef boost::iterators::detail::minimum_category_impl<
0071         ::boost::is_convertible<T1,T2>::value
0072       , ::boost::is_convertible<T2,T1>::value
0073     > outer;
0074 
0075     typedef typename outer::template apply<T1,T2> inner;
0076     typedef typename inner::type type;
0077 
0078     BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2))
0079 };
0080 
0081 template <>
0082 struct minimum_category<mpl::_1,mpl::_2>
0083 {
0084     template <class T1, class T2>
0085     struct apply : minimum_category<T1,T2>
0086     {};
0087 
0088     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,minimum_category,(mpl::_1,mpl::_2))
0089 };
0090 
0091 } // namespace iterators
0092 
0093 } // namespace boost
0094 
0095 #endif // BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_