]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // (C) Copyright Edward Diener 2011,2012,2013 | |
3 | // Use, modification and distribution are subject to the Boost Software License, | |
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt). | |
6 | ||
7 | #if !defined(BOOST_TTI_DETAIL_TYPE_HPP) | |
8 | #define BOOST_TTI_DETAIL_TYPE_HPP | |
9 | ||
10 | #include <boost/config.hpp> | |
11 | #include <boost/mpl/apply.hpp> | |
12 | #include <boost/mpl/bool.hpp> | |
13 | #include <boost/mpl/eval_if.hpp> | |
14 | #include <boost/mpl/has_xxx.hpp> | |
15 | #include <boost/preprocessor/cat.hpp> | |
16 | #include <boost/tti/detail/ddeftype.hpp> | |
17 | #include <boost/tti/detail/dlambda.hpp> | |
18 | #include <boost/tti/gen/namespace_gen.hpp> | |
19 | #include <boost/type_traits/is_class.hpp> | |
20 | ||
21 | #define BOOST_TTI_DETAIL_TRAIT_INVOKE_HAS_TYPE(trait,name) \ | |
22 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_MFC> \ | |
23 | struct BOOST_PP_CAT(trait,_detail_type_invoke) : \ | |
24 | boost::mpl::apply<BOOST_TTI_DETAIL_TP_MFC,typename BOOST_TTI_DETAIL_TP_T::name> \ | |
25 | { \ | |
26 | }; \ | |
27 | /**/ | |
28 | ||
29 | #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP_CHOOSE(trait,name) \ | |
30 | BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(trait,_detail_type_mpl), name, false) \ | |
31 | BOOST_TTI_DETAIL_TRAIT_INVOKE_HAS_TYPE(trait,name) \ | |
32 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_B> \ | |
33 | struct BOOST_PP_CAT(trait,_detail_type_op_choose) \ | |
34 | { \ | |
35 | BOOST_MPL_ASSERT((BOOST_TTI_NAMESPACE::detail::is_lambda_expression<BOOST_TTI_DETAIL_TP_U>)); \ | |
36 | typedef typename BOOST_PP_CAT(trait,_detail_type_invoke)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_U>::type type; \ | |
37 | }; \ | |
38 | \ | |
39 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U> \ | |
40 | struct BOOST_PP_CAT(trait,_detail_type_op_choose)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_U,boost::mpl::false_::type> : \ | |
41 | boost::mpl::false_ \ | |
42 | { \ | |
43 | }; \ | |
44 | \ | |
45 | template<class BOOST_TTI_DETAIL_TP_T> \ | |
46 | struct BOOST_PP_CAT(trait,_detail_type_op_choose)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_NAMESPACE::detail::deftype,boost::mpl::true_::type> : \ | |
47 | boost::mpl::true_ \ | |
48 | { \ | |
49 | }; \ | |
50 | /**/ | |
51 | ||
52 | #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP(trait,name) \ | |
53 | BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP_CHOOSE(trait,name) \ | |
54 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U> \ | |
55 | struct BOOST_PP_CAT(trait,_detail_type_op) : \ | |
56 | BOOST_PP_CAT(trait,_detail_type_op_choose) \ | |
57 | < \ | |
58 | BOOST_TTI_DETAIL_TP_T, \ | |
59 | BOOST_TTI_DETAIL_TP_U, \ | |
60 | typename BOOST_PP_CAT(trait,_detail_type_mpl)<BOOST_TTI_DETAIL_TP_T>::type \ | |
61 | > \ | |
62 | { \ | |
63 | }; \ | |
64 | /**/ | |
65 | ||
66 | #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE(trait,name) \ | |
67 | BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_OP(trait,name) \ | |
68 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_U> \ | |
69 | struct BOOST_PP_CAT(trait,_detail_type) : \ | |
70 | boost::mpl::eval_if \ | |
71 | < \ | |
72 | boost::is_class<BOOST_TTI_DETAIL_TP_T>, \ | |
73 | BOOST_PP_CAT(trait,_detail_type_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_U>, \ | |
74 | boost::mpl::false_ \ | |
75 | > \ | |
76 | { \ | |
77 | }; \ | |
78 | /**/ | |
79 | ||
80 | #endif // BOOST_TTI_DETAIL_TYPE_HPP |