1 | // Copyright Daniel Wallin 2006. |
2 | // Copyright Cromwell D. Enage 2017. |
3 | // Distributed under the Boost Software License, Version 1.0. |
4 | // (See accompanying file LICENSE_1_0.txt or copy at |
5 | // http://www.boost.org/LICENSE_1_0.txt) |
6 | |
7 | #ifndef BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP |
8 | #define BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP |
9 | |
10 | namespace boost { namespace parameter { namespace aux { |
11 | |
12 | struct template_keyword_base |
13 | { |
14 | }; |
15 | }}} // namespace boost::parameter::aux |
16 | |
17 | #include <boost/parameter/config.hpp> |
18 | |
19 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) |
20 | #include <type_traits> |
21 | |
22 | namespace boost { namespace parameter { namespace aux { |
23 | |
24 | template <typename T> |
25 | using is_template_keyword = ::std::is_base_of< |
26 | ::boost::parameter::aux::template_keyword_base |
27 | , typename ::std::remove_const< |
28 | typename ::std::remove_reference<T>::type |
29 | >::type |
30 | >; |
31 | }}} // namespace boost::parameter::aux |
32 | |
33 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) |
34 | #include <boost/mpl/bool.hpp> |
35 | #include <boost/mpl/if.hpp> |
36 | #include <boost/type_traits/remove_const.hpp> |
37 | |
38 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) |
39 | #include <boost/type_traits/is_base_of.hpp> |
40 | #include <boost/type_traits/remove_reference.hpp> |
41 | #else |
42 | #include <boost/type_traits/is_convertible.hpp> |
43 | #include <boost/type_traits/is_lvalue_reference.hpp> |
44 | #endif |
45 | |
46 | namespace boost { namespace parameter { namespace aux { |
47 | |
48 | #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) |
49 | template <typename T> |
50 | struct is_template_keyword_aux |
51 | : ::boost::mpl::if_< |
52 | ::boost::is_convertible< |
53 | T* |
54 | , ::boost::parameter::aux::template_keyword_base const* |
55 | > |
56 | , ::boost::mpl::true_ |
57 | , ::boost::mpl::false_ |
58 | >::type |
59 | { |
60 | }; |
61 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING |
62 | |
63 | template <typename T> |
64 | struct is_template_keyword |
65 | : ::boost::mpl::if_< |
66 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) |
67 | // Cannot use is_convertible<> to check if T is derived from |
68 | // template_keyword_base. -- Cromwell D. Enage |
69 | ::boost::is_base_of< |
70 | ::boost::parameter::aux::template_keyword_base |
71 | , typename ::boost::remove_const< |
72 | typename ::boost::remove_reference<T>::type |
73 | >::type |
74 | > |
75 | , ::boost::mpl::true_ |
76 | , ::boost::mpl::false_ |
77 | #else |
78 | ::boost::is_lvalue_reference<T> |
79 | , ::boost::mpl::false_ |
80 | , ::boost::parameter::aux::is_template_keyword_aux<T> |
81 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING |
82 | >::type |
83 | { |
84 | }; |
85 | }}} // namespace boost::parameter::aux |
86 | |
87 | #endif // BOOST_PARAMETER_CAN_USE_MP11 |
88 | #endif // include guard |
89 | |
90 | |