1 /* Copyright 2003-2014 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)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_IS_TRANSPARENT_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_IS_TRANSPARENT_HPP
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/mpl/bool.hpp>
18 #include <boost/type_traits/intrinsics.hpp>
22 namespace multi_index{
26 /* Metafunction that checks if f(arg,arg2) executes without argument type
27 * conversion. By default (i.e. when it cannot be determined) it evaluates to
31 template<typename F,typename Arg1,typename Arg2,typename=void>
32 struct is_transparent:mpl::true_{};
34 } /* namespace multi_index::detail */
36 } /* namespace multi_index */
38 } /* namespace boost */
40 #if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_SFINAE_EXPR)&& \
41 !defined(BOOST_NO_CXX11_DECLTYPE)&& \
42 (defined(BOOST_NO_CXX11_FINAL)||defined(BOOST_IS_FINAL))
44 #include <boost/mpl/and.hpp>
45 #include <boost/mpl/not.hpp>
46 #include <boost/mpl/or.hpp>
47 #include <boost/type_traits/function_traits.hpp>
48 #include <boost/type_traits/is_class.hpp>
49 #include <boost/type_traits/is_final.hpp>
50 #include <boost/type_traits/is_function.hpp>
51 #include <boost/type_traits/is_same.hpp>
52 #include <boost/type_traits/remove_pointer.hpp>
53 #include <boost/utility/declval.hpp>
54 #include <boost/utility/enable_if.hpp>
58 namespace multi_index{
62 struct not_is_transparent_result_type{};
64 template<typename F,typename Arg1,typename Arg2>
65 struct is_transparent_class_helper:F
68 template<typename T,typename Q>
69 not_is_transparent_result_type operator()(const T&,const Q&)const;
72 template<typename F,typename Arg1,typename Arg2,typename=void>
73 struct is_transparent_class:mpl::true_{};
75 template<typename F,typename Arg1,typename Arg2>
76 struct is_transparent_class<
81 declval<const is_transparent_class_helper<F,Arg1,Arg2> >()(
82 declval<const Arg1&>(),declval<const Arg2&>())
84 not_is_transparent_result_type
89 template<typename F,typename Arg1,typename Arg2>
90 struct is_transparent<
95 mpl::not_<is_final<F> > /* is_transparent_class_helper derives from F */
98 >:is_transparent_class<F,Arg1,Arg2>{};
100 template<typename F,typename Arg1,typename Arg2,typename=void>
101 struct is_transparent_function:mpl::true_{};
103 template<typename F,typename Arg1,typename Arg2>
104 struct is_transparent_function<
109 is_same<typename function_traits<F>::arg1_type,const Arg1&>,
110 is_same<typename function_traits<F>::arg1_type,Arg1>
113 is_same<typename function_traits<F>::arg2_type,const Arg2&>,
114 is_same<typename function_traits<F>::arg2_type,Arg2>
120 template<typename F,typename Arg1,typename Arg2>
121 struct is_transparent<
124 is_function<typename remove_pointer<F>::type>
126 >:is_transparent_function<typename remove_pointer<F>::type,Arg1,Arg2>{};
128 } /* namespace multi_index::detail */
130 } /* namespace multi_index */
132 } /* namespace boost */