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