nested_xxx_if_not_ph.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright 2006-2009 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_NESTED_XXX_IF_NOT_PH_HPP
  9. #define BOOST_FLYWEIGHT_DETAIL_NESTED_XXX_IF_NOT_PH_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/flyweight/detail/is_placeholder_expr.hpp>
  14. #include <boost/mpl/if.hpp>
  15. /* nested_##name##_if_not_placeholder_expression<T>::type is T::name unless
  16. * T is an MPL placeholder expression, in which case it defaults to int.
  17. */
  18. #define BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(name) \
  19. struct nested_##name##_if_not_placeholder_expression_helper \
  20. { \
  21. typedef int name; \
  22. }; \
  23. \
  24. template<typename T> \
  25. struct nested_##name##_if_not_placeholder_expression \
  26. { \
  27. typedef typename boost::mpl::if_< \
  28. boost::flyweights::detail::is_placeholder_expression<T>, \
  29. nested_##name##_if_not_placeholder_expression_helper, \
  30. T \
  31. >::type::name type; \
  32. };
  33. #endif