to_array.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_TUPLE_TO_ARRAY_HPP
  14. # define BOOST_PREPROCESSOR_TUPLE_TO_ARRAY_HPP
  15. #
  16. # include <boost/preprocessor/cat.hpp>
  17. # include <boost/preprocessor/config/config.hpp>
  18. # include <boost/preprocessor/control/if.hpp>
  19. # include <boost/preprocessor/facilities/overload.hpp>
  20. # include <boost/preprocessor/tuple/size.hpp>
  21. # include <boost/preprocessor/variadic/size.hpp>
  22. # include <boost/preprocessor/variadic/has_opt.hpp>
  23. #
  24. # /* BOOST_PP_TUPLE_TO_ARRAY */
  25. #
  26. # if BOOST_PP_VARIADICS_MSVC
  27. # define BOOST_PP_TUPLE_TO_ARRAY(...) BOOST_PP_TUPLE_TO_ARRAY_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_TO_ARRAY_, __VA_ARGS__), (__VA_ARGS__))
  28. # define BOOST_PP_TUPLE_TO_ARRAY_I(m, args) BOOST_PP_TUPLE_TO_ARRAY_II(m, args)
  29. # define BOOST_PP_TUPLE_TO_ARRAY_II(m, args) BOOST_PP_CAT(m ## args,)
  30. # define BOOST_PP_TUPLE_TO_ARRAY_1(tuple) (BOOST_PP_TUPLE_SIZE(tuple), tuple)
  31. # else
  32. # define BOOST_PP_TUPLE_TO_ARRAY(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_TO_ARRAY_, __VA_ARGS__)(__VA_ARGS__)
  33. # if BOOST_PP_VARIADIC_HAS_OPT()
  34. # define BOOST_PP_TUPLE_TO_ARRAY_1(tuple) BOOST_PP_TUPLE_TO_ARRAY_1_SIZE(BOOST_PP_VARIADIC_SIZE tuple, tuple)
  35. # define BOOST_PP_TUPLE_TO_ARRAY_1_SIZE(size,tuple) (BOOST_PP_IF(size,size,1), tuple)
  36. # else
  37. # define BOOST_PP_TUPLE_TO_ARRAY_1(tuple) (BOOST_PP_VARIADIC_SIZE tuple, tuple)
  38. # endif
  39. # endif
  40. # define BOOST_PP_TUPLE_TO_ARRAY_2(size, tuple) (size, tuple)
  41. #
  42. # endif