to_array.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # /* **************************************************************************
  2. # * *
  3. # * (C) Copyright Edward Diener 2011. *
  4. # * (C) Copyright Paul Mensonides 2011. *
  5. # * Distributed under the Boost Software License, Version 1.0. (See *
  6. # * accompanying file LICENSE_1_0.txt or copy at *
  7. # * http://www.boost.org/LICENSE_1_0.txt) *
  8. # * *
  9. # ************************************************************************** */
  10. #
  11. # /* See http://www.boost.org for most recent version. */
  12. #
  13. # ifndef BOOST_PREPROCESSOR_VARIADIC_TO_ARRAY_HPP
  14. # define BOOST_PREPROCESSOR_VARIADIC_TO_ARRAY_HPP
  15. #
  16. # include <boost/preprocessor/config/config.hpp>
  17. # include <boost/preprocessor/control/if.hpp>
  18. # include <boost/preprocessor/tuple/to_array.hpp>
  19. # include <boost/preprocessor/variadic/has_opt.hpp>
  20. # include <boost/preprocessor/variadic/size.hpp>
  21. #
  22. # /* BOOST_PP_VARIADIC_TO_ARRAY */
  23. #
  24. # if BOOST_PP_VARIADIC_HAS_OPT()
  25. # if BOOST_PP_VARIADICS_MSVC
  26. # define BOOST_PP_VARIADIC_TO_ARRAY_NON_EMPTY(...) BOOST_PP_TUPLE_TO_ARRAY_2(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),(__VA_ARGS__))
  27. # else
  28. # define BOOST_PP_VARIADIC_TO_ARRAY_NON_EMPTY(...) BOOST_PP_TUPLE_TO_ARRAY((__VA_ARGS__))
  29. # endif
  30. # define BOOST_PP_VARIADIC_TO_ARRAY_EMPTY(...) (0,())
  31. # define BOOST_PP_VARIADIC_TO_ARRAY(...) BOOST_PP_IF(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),BOOST_PP_VARIADIC_TO_ARRAY_NON_EMPTY,BOOST_PP_VARIADIC_TO_ARRAY_EMPTY)(__VA_ARGS__)
  32. # elif BOOST_PP_VARIADICS_MSVC
  33. # define BOOST_PP_VARIADIC_TO_ARRAY(...) BOOST_PP_TUPLE_TO_ARRAY_2(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),(__VA_ARGS__))
  34. # else
  35. # define BOOST_PP_VARIADIC_TO_ARRAY(...) BOOST_PP_TUPLE_TO_ARRAY((__VA_ARGS__))
  36. # endif
  37. #
  38. # endif