pp_variadic.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // (C) Copyright Gennadiy Rozental 2001.
  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. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. //!@file
  8. //!@brief few helpers for working with variadic macros
  9. // ***************************************************************************
  10. #ifndef BOOST_TEST_PP_VARIADIC_HPP_021515GER
  11. #define BOOST_TEST_PP_VARIADIC_HPP_021515GER
  12. // Boost
  13. #include <boost/preprocessor/control/iif.hpp>
  14. #include <boost/preprocessor/comparison/equal.hpp>
  15. #include <boost/preprocessor/variadic/size.hpp>
  16. //____________________________________________________________________________//
  17. #if BOOST_PP_VARIADICS
  18. #if BOOST_PP_VARIADICS_MSVC
  19. # define BOOST_TEST_INVOKE_VARIADIC( tool, ... ) BOOST_PP_CAT( tool (__VA_ARGS__), )
  20. #else
  21. # define BOOST_TEST_INVOKE_VARIADIC( tool, ... ) tool (__VA_ARGS__)
  22. #endif
  23. //____________________________________________________________________________//
  24. /// if sizeof(__VA_ARGS__) == N: F1(__VA_ARGS__)
  25. /// else: F2(__VA_ARGS__)
  26. #define BOOST_TEST_INVOKE_IF_N_ARGS( N, F1, F2, ... ) \
  27. BOOST_TEST_INVOKE_VARIADIC( \
  28. BOOST_PP_IIF( \
  29. BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), N), \
  30. F1, \
  31. F2), \
  32. __VA_ARGS__ ) \
  33. /**/
  34. //____________________________________________________________________________//
  35. #endif /* BOOST_PP_VARIADICS */
  36. #endif // BOOST_TEST_PP_VARIADIC_HPP_021515GER
  37. // EOF