1 // Copyright David Abrahams 2003. Use, modification and distribution is
\r
2 // subject to the Boost Software License, Version 1.0. (See accompanying
\r
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
\r
4 #ifndef MINIMUM_CATEGORY_DWA20031119_HPP
\r
5 # define MINIMUM_CATEGORY_DWA20031119_HPP
\r
7 # include <boost/type_traits/is_convertible.hpp>
\r
8 # include <boost/type_traits/is_same.hpp>
\r
10 # include <boost/mpl/aux_/lambda_support.hpp>
\r
12 namespace boost { namespace detail {
\r
14 // Returns the minimum category type or error_type
\r
15 // if T1 and T2 are unrelated.
\r
17 // For compilers not supporting is_convertible this only
\r
18 // works with the new boost return and traversal category
\r
19 // types. The exact boost _types_ are required. No derived types
\r
23 template <bool GreaterEqual, bool LessEqual>
\r
24 struct minimum_category_impl
\r
25 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
\r
27 template <class T1, class T2> struct apply
\r
36 template <class T1, class T2>
\r
37 struct error_not_related_by_convertibility;
\r
40 struct minimum_category_impl<true,false>
\r
42 template <class T1, class T2> struct apply
\r
49 struct minimum_category_impl<false,true>
\r
51 template <class T1, class T2> struct apply
\r
58 struct minimum_category_impl<true,true>
\r
60 template <class T1, class T2> struct apply
\r
62 BOOST_STATIC_ASSERT((is_same<T1,T2>::value));
\r
68 struct minimum_category_impl<false,false>
\r
70 template <class T1, class T2> struct apply
\r
71 : error_not_related_by_convertibility<T1,T2>
\r
76 template <class T1 = mpl::_1, class T2 = mpl::_2>
\r
77 struct minimum_category
\r
79 typedef minimum_category_impl<
\r
80 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround
\r
81 is_same<T2,int>::value ||
\r
83 ::boost::is_convertible<T1,T2>::value
\r
84 , ::boost::is_convertible<T2,T1>::value
\r
85 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround
\r
86 || is_same<T1,int>::value
\r
90 typedef typename outer::template apply<T1,T2> inner;
\r
91 typedef typename inner::type type;
\r
93 BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2))
\r
97 struct minimum_category<mpl::_1,mpl::_2>
\r
99 template <class T1, class T2>
\r
100 struct apply : minimum_category<T1,T2>
\r
103 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,minimum_category,(mpl::_1,mpl::_2))
\r
106 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround
\r
108 struct minimum_category<int,int>
\r
114 }} // namespace boost::detail
\r
116 #endif // MINIMUM_CATEGORY_DWA20031119_HPP
\r