Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / tti / detail / dtemplate.hpp
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_TEMPLATE_HPP)
8 #define BOOST_TTI_DETAIL_TEMPLATE_HPP
9
10 #include <boost/config.hpp>
11 #include <boost/mpl/bool.hpp>
12 #include <boost/mpl/eval_if.hpp>
13 #include <boost/mpl/has_xxx.hpp>
14 #include <boost/preprocessor/cat.hpp>
15 #include <boost/preprocessor/debug/assert.hpp>
16 #include <boost/preprocessor/facilities/is_empty.hpp>
17 #include <boost/type_traits/is_class.hpp>
18
19 #define BOOST_TTI_DETAIL_IS_HELPER_BOOST_PP_NIL
20
21 #define BOOST_TTI_DETAIL_IS_NIL(param) \
22   BOOST_PP_IS_EMPTY \
23     ( \
24     BOOST_PP_CAT(BOOST_TTI_DETAIL_IS_HELPER_,param) \
25     ) \
26 /**/
27
28 #define BOOST_TTI_DETAIL_TRAIT_ASSERT_NOT_NIL(trait,name,params) \
29   BOOST_PP_ASSERT_MSG(0, "The parameter must be BOOST_PP_NIL") \
30 /**/
31
32 #define BOOST_TTI_DETAIL_TRAIT_CHECK_IS_NIL(trait,name,params) \
33   BOOST_PP_IIF \
34     ( \
35     BOOST_TTI_DETAIL_IS_NIL(params), \
36     BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE, \
37     BOOST_TTI_DETAIL_TRAIT_ASSERT_NOT_NIL \
38     ) \
39     (trait,name,params) \
40 /**/
41
42 #define BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_THT(trait,name) \
43   BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(BOOST_PP_CAT(trait,_detail_mpl), name, false) \
44   template<class BOOST_TTI_DETAIL_TP_T> \
45   struct BOOST_PP_CAT(trait,_tht) : \
46     BOOST_PP_CAT(trait,_detail_mpl)<BOOST_TTI_DETAIL_TP_T> \
47     { \
48     }; \
49 /**/
50
51 #define BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE(trait,name,params) \
52   BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_THT(trait,name) \
53   template<class BOOST_TTI_DETAIL_TP_T> \
54   struct trait \
55     { \
56     typedef typename \
57     boost::mpl::eval_if \
58         < \
59         boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
60         BOOST_PP_CAT(trait,_tht)<BOOST_TTI_DETAIL_TP_T>, \
61         boost::mpl::false_ \
62         >::type type; \
63     BOOST_STATIC_CONSTANT(bool,value=type::value); \
64     }; \
65 /**/
66
67 #endif // !BOOST_TTI_DETAIL_TEMPLATE_HPP