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