not_placeholder_expr.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
  9. #define BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
  10. #if defined(_MSC_VER)&&(_MSC_VER>=1200)
  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. /* The default trick on which the macro is based, namely adding a int=0
  30. * defaulted template parameter, does not work in GCC prior to 4.2 due to
  31. * an unfortunate compiler non-standard extension, as explained in
  32. * http://lists.boost.org/boost-users/2007/07/29866.php
  33. * We resort to an uglier technique, adding defaulted template parameters
  34. * so as to exceed BOOST_MPL_LIMIT_METAFUNCTION_ARITY.
  35. */
  36. #include <boost/mpl/limits/arity.hpp>
  37. #include <boost/preprocessor/facilities/intercept.hpp>
  38. #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  39. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION \
  40. BOOST_PP_ENUM_TRAILING_PARAMS( \
  41. BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename=int BOOST_PP_INTERCEPT)
  42. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF \
  43. BOOST_PP_ENUM_TRAILING_PARAMS( \
  44. BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT)
  45. #else
  46. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION ,int=0
  47. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF ,int
  48. #endif
  49. #endif