not_placeholder_expr.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright 2006-2018 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. #ifndef BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
  9. #define BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. /* BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION can be inserted at the end
  14. * of a class template parameter declaration:
  15. * template<
  16. * typename X0,...,typename Xn
  17. * BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION
  18. * >
  19. * struct foo...
  20. * to prevent instantiations from being treated as MPL placeholder
  21. * expressions in the presence of placeholder arguments; this is useful
  22. * to avoid masking of a metafunction class nested ::apply during
  23. * MPL invocation.
  24. */
  25. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  26. #include <boost/detail/workaround.hpp>
  27. #if BOOST_WORKAROUND(__GNUC__, <4)||\
  28. BOOST_WORKAROUND(__GNUC__,==4)&&(__GNUC_MINOR__<2)||\
  29. BOOST_WORKAROUND(__GNUC__, ==7)&&( __cplusplus>=201703L)||\
  30. BOOST_WORKAROUND(__GNUC__, >=8)&&( __cplusplus>=201103L)
  31. /* The default trick on which the macro is based, namely adding a int=0
  32. * defaulted template parameter, does not work in GCC prior to 4.2 due to
  33. * an unfortunate compiler non-standard extension, as explained in
  34. * http://lists.boost.org/boost-users/2007/07/29866.php
  35. * As it happens, GCC 7 in C++17 mode and GCC 8 (and presumably later) in
  36. * C++11 mode (and presumably later) go back to this old behavior, anticipating
  37. * the resolution of CWG DR 150 (see P0522R0).
  38. * In these cases we resort to an uglier technique, adding defaulted template
  39. * parameters so as to exceed BOOST_MPL_LIMIT_METAFUNCTION_ARITY.
  40. */
  41. #include <boost/mpl/limits/arity.hpp>
  42. #include <boost/preprocessor/facilities/intercept.hpp>
  43. #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  44. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION \
  45. BOOST_PP_ENUM_TRAILING_PARAMS( \
  46. BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename=int BOOST_PP_INTERCEPT)
  47. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF \
  48. BOOST_PP_ENUM_TRAILING_PARAMS( \
  49. BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT)
  50. #else
  51. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION ,int=0
  52. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF ,int
  53. #endif
  54. #endif