]>
Commit | Line | Data |
---|---|---|
92f5a8d4 | 1 | /* Copyright 2006-2018 Joaquin M Lopez Munoz. |
7c673cae FG |
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) | |
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)||\ | |
92f5a8d4 TL |
33 | BOOST_WORKAROUND(__GNUC__,==4)&&(__GNUC_MINOR__<2)||\ |
34 | BOOST_WORKAROUND(__GNUC__, ==7)&&( __cplusplus>=201703L)||\ | |
35 | BOOST_WORKAROUND(__GNUC__, >=8)&&( __cplusplus>=201103L) | |
7c673cae FG |
36 | /* The default trick on which the macro is based, namely adding a int=0 |
37 | * defaulted template parameter, does not work in GCC prior to 4.2 due to | |
38 | * an unfortunate compiler non-standard extension, as explained in | |
39 | * http://lists.boost.org/boost-users/2007/07/29866.php | |
92f5a8d4 TL |
40 | * As it happens, GCC 7 in C++17 mode and GCC 8 (and presumably later) in |
41 | * C++11 mode (and presumably later) go back to this old behavior, anticipating | |
42 | * the resolution of CWG DR 150 (see P0522R0). | |
43 | * In these cases we resort to an uglier technique, adding defaulted template | |
44 | * parameters so as to exceed BOOST_MPL_LIMIT_METAFUNCTION_ARITY. | |
7c673cae FG |
45 | */ |
46 | ||
47 | #include <boost/mpl/limits/arity.hpp> | |
48 | #include <boost/preprocessor/facilities/intercept.hpp> | |
49 | #include <boost/preprocessor/repetition/enum_trailing_params.hpp> | |
50 | ||
51 | #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION \ | |
52 | BOOST_PP_ENUM_TRAILING_PARAMS( \ | |
53 | BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename=int BOOST_PP_INTERCEPT) | |
54 | #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF \ | |
55 | BOOST_PP_ENUM_TRAILING_PARAMS( \ | |
56 | BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT) | |
57 | ||
58 | #else | |
59 | #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION ,int=0 | |
60 | #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF ,int | |
61 | #endif | |
62 | ||
63 | #endif |