Chris@102
|
1 /* Copyright 2003-2014 Joaquin M Lopez Munoz.
|
Chris@102
|
2 * Distributed under the Boost Software License, Version 1.0.
|
Chris@102
|
3 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
4 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
5 *
|
Chris@102
|
6 * See http://www.boost.org/libs/multi_index for library home page.
|
Chris@102
|
7 */
|
Chris@102
|
8
|
Chris@102
|
9 #ifndef BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
|
Chris@102
|
10 #define BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
|
Chris@102
|
11
|
Chris@102
|
12 #if defined(_MSC_VER)
|
Chris@102
|
13 #pragma once
|
Chris@102
|
14 #endif
|
Chris@102
|
15
|
Chris@102
|
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
Chris@102
|
17 #include <boost/mpl/bool.hpp>
|
Chris@102
|
18 #include <boost/type_traits/intrinsics.hpp>
|
Chris@102
|
19
|
Chris@102
|
20 /* Metafunctions to check if f(arg1,arg2) promotes either arg1 to the type of
|
Chris@102
|
21 * arg2 or viceversa. By default, (i.e. if it cannot be determined), no
|
Chris@102
|
22 * promotion is assumed.
|
Chris@102
|
23 */
|
Chris@102
|
24
|
Chris@102
|
25 #if !defined(BOOST_IS_CONVERTIBLE)
|
Chris@102
|
26
|
Chris@102
|
27 namespace boost{
|
Chris@102
|
28
|
Chris@102
|
29 namespace multi_index{
|
Chris@102
|
30
|
Chris@102
|
31 namespace detail{
|
Chris@102
|
32
|
Chris@102
|
33 template<typename F,typename Arg1,typename Arg2>
|
Chris@102
|
34 struct promotes_1st_arg:mpl::false_{};
|
Chris@102
|
35
|
Chris@102
|
36 template<typename F,typename Arg1,typename Arg2>
|
Chris@102
|
37 struct promotes_2nd_arg:mpl::false_{};
|
Chris@102
|
38
|
Chris@102
|
39 } /* namespace multi_index::detail */
|
Chris@102
|
40
|
Chris@102
|
41 } /* namespace multi_index */
|
Chris@102
|
42
|
Chris@102
|
43 } /* namespace boost */
|
Chris@102
|
44
|
Chris@102
|
45 #else
|
Chris@102
|
46
|
Chris@102
|
47 #include <boost/mpl/and.hpp>
|
Chris@102
|
48 #include <boost/mpl/not.hpp>
|
Chris@102
|
49 #include <boost/multi_index/detail/is_transparent.hpp>
|
Chris@102
|
50 #include <boost/type_traits/is_convertible.hpp>
|
Chris@102
|
51
|
Chris@102
|
52 namespace boost{
|
Chris@102
|
53
|
Chris@102
|
54 namespace multi_index{
|
Chris@102
|
55
|
Chris@102
|
56 namespace detail{
|
Chris@102
|
57
|
Chris@102
|
58 template<typename F,typename Arg1,typename Arg2>
|
Chris@102
|
59 struct promotes_1st_arg:
|
Chris@102
|
60 mpl::and_<
|
Chris@102
|
61 mpl::not_<is_transparent<F,Arg1,Arg2> >,
|
Chris@102
|
62 is_convertible<const Arg1,Arg2>,
|
Chris@102
|
63 is_transparent<F,Arg2,Arg2>
|
Chris@102
|
64 >
|
Chris@102
|
65 {};
|
Chris@102
|
66
|
Chris@102
|
67 template<typename F,typename Arg1,typename Arg2>
|
Chris@102
|
68 struct promotes_2nd_arg:
|
Chris@102
|
69 mpl::and_<
|
Chris@102
|
70 mpl::not_<is_transparent<F,Arg1,Arg2> >,
|
Chris@102
|
71 is_convertible<const Arg2,Arg1>,
|
Chris@102
|
72 is_transparent<F,Arg1,Arg1>
|
Chris@102
|
73 >
|
Chris@102
|
74 {};
|
Chris@102
|
75
|
Chris@102
|
76 } /* namespace multi_index::detail */
|
Chris@102
|
77
|
Chris@102
|
78 } /* namespace multi_index */
|
Chris@102
|
79
|
Chris@102
|
80 } /* namespace boost */
|
Chris@102
|
81
|
Chris@102
|
82 #endif /* defined(BOOST_IS_CONVERTIBLE) */
|
Chris@102
|
83 #endif
|