match.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright David Abrahams 2005. Distributed under the Boost
  2. // Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef BOOST_PARAMETER_MATCH_DWA2005714_HPP
  5. # define BOOST_PARAMETER_MATCH_DWA2005714_HPP
  6. # include <boost/detail/workaround.hpp>
  7. # include <boost/preprocessor/seq/enum.hpp>
  8. # if BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
  9. // Temporary version of BOOST_PP_SEQ_ENUM until Paul M. integrates the workaround.
  10. # define BOOST_PARAMETER_SEQ_ENUM_I(size,seq) BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, size) seq
  11. # define BOOST_PARAMETER_SEQ_ENUM(seq) BOOST_PARAMETER_SEQ_ENUM_I(BOOST_PP_SEQ_SIZE(seq), seq)
  12. # else
  13. # define BOOST_PARAMETER_SEQ_ENUM(seq) BOOST_PP_SEQ_ENUM(seq)
  14. # endif
  15. # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  16. # include <boost/parameter/config.hpp>
  17. # include <boost/parameter/aux_/void.hpp>
  18. # include <boost/preprocessor/arithmetic/sub.hpp>
  19. # include <boost/preprocessor/facilities/intercept.hpp>
  20. # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  21. # define BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes) \
  22. BOOST_PP_ENUM_TRAILING_PARAMS( \
  23. BOOST_PP_SUB( \
  24. BOOST_PARAMETER_MAX_ARITY \
  25. , BOOST_PP_SEQ_SIZE(ArgTypes) \
  26. ) \
  27. , ::boost::parameter::void_ BOOST_PP_INTERCEPT \
  28. )
  29. # else
  30. # define BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes)
  31. # endif
  32. //
  33. // Generates, e.g.
  34. //
  35. // typename dfs_params::match<A1,A2>::type name = dfs_params()
  36. //
  37. // with workarounds for Borland compatibility.
  38. //
  39. # define BOOST_PARAMETER_MATCH(ParameterSpec, ArgTypes, name) \
  40. typename ParameterSpec ::match< \
  41. BOOST_PARAMETER_SEQ_ENUM(ArgTypes) \
  42. BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes) \
  43. >::type name = ParameterSpec ()
  44. #endif // BOOST_PARAMETER_MATCH_DWA2005714_HPP