a62bd09301bd27ab66958cef9e80fafcaa9a5a58
[platform/upstream/boost.git] / boost / flyweight / detail / not_placeholder_expr.hpp
1 /* Copyright 2006-2008 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/flyweight for library home page.
7  */
8
9 #ifndef BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
10 #define BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
11
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
13 #pragma once
14 #endif
15
16 /* BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION can be inserted at the end
17  * of a class template parameter declaration:
18  *   template<
19  *     typename X0,...,typename Xn
20  *     BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION  
21  *   >
22  *   struct foo...
23  * to prevent instantiations from being treated as MPL placeholder
24  * expressions in the presence of placeholder arguments; this is useful
25  * to avoid masking of a metafunction class nested ::apply during
26  * MPL invocation.
27  */
28
29 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
30 #include <boost/detail/workaround.hpp>
31
32 #if BOOST_WORKAROUND(__GNUC__, <4)||\
33     BOOST_WORKAROUND(__GNUC__,==4)&&(__GNUC_MINOR__<2)
34 /* The default trick on which the macro is based, namely adding a int=0
35  * defaulted template parameter, does not work in GCC prior to 4.2 due to
36  * an unfortunate compiler non-standard extension, as explained in
37  *   http://lists.boost.org/boost-users/2007/07/29866.php
38  * We resort to an uglier technique, adding defaulted template parameters
39  * so as to exceed BOOST_MPL_LIMIT_METAFUNCTION_ARITY.
40  */
41
42 #include <boost/mpl/limits/arity.hpp>
43 #include <boost/preprocessor/facilities/intercept.hpp>
44 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
45
46 #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION                  \
47 BOOST_PP_ENUM_TRAILING_PARAMS(                                        \
48   BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename=int BOOST_PP_INTERCEPT)
49 #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF              \
50 BOOST_PP_ENUM_TRAILING_PARAMS(                                        \
51   BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT)
52
53 #else
54 #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION  ,int=0
55 #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF  ,int
56 #endif
57
58 #endif