to_tuple.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // (C) Copyright Edward Diener 2011-2015
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #if !defined(BOOST_VMD_TO_TUPLE_HPP)
  6. #define BOOST_VMD_TO_TUPLE_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/vmd/detail/sequence_to_tuple.hpp>
  10. /*
  11. The succeeding comments in this file are in doxygen format.
  12. */
  13. /** \file
  14. */
  15. /** \def BOOST_VMD_TO_TUPLE(...)
  16. \brief Converts a sequence to a Boost PP tuple whose elements are the elements of the sequence.
  17. ... = Variadic parameters.
  18. The first variadic parameter is required and is the sequence to convert.
  19. Further optional variadic parameters can be return type parameters. Return type
  20. parameters allow each element in the sequence to be converted to a two-element
  21. tuple where the first tuple element is the type and the second tuple element
  22. is the element data.
  23. The BOOST_VMD_RETURN_NO_TYPE, the default, does not return the type as part of each
  24. converted element but just the data. All of the rest return the type and data as the
  25. two-element tuple. If BOOST_VMD_RETURN_TYPE is specified the specific type of the element
  26. is returned in the tuple. If BOOST_VMD_RETURN_TYPE_ARRAY is specified an array type is
  27. returned if the element is an array, else a tuple type is returned if the element is a tuple,
  28. else the actual type is returned for non-tuple data. If BOOST_VMD_RETURN_TYPE_LIST is specified
  29. a list type is returned if the element is a list, else a tuple type is returned if the element
  30. is a tuple, else the actual type is returned for non-tuple data. If BOOST_VMD_RETURN_TYPE_TUPLE
  31. is specified a tuple type is returned for all tuple-like data, else the actual type is returned
  32. for non-tuple data. If more than one return type optional parameter is specified the last one
  33. specified determines the return type.
  34. returns = A Boost PP tuple. If the sequence is empty the return is emptiness
  35. since an empty tuple does not exist. If an optional return type other
  36. than BOOST_VMD_RETURN_NO_TYPE is specified the type and the data of
  37. each element is returned as the tuple element. Otherwise just the data
  38. is returned as the tuple element, which is the default.
  39. */
  40. #define BOOST_VMD_TO_TUPLE(...) \
  41. BOOST_VMD_DETAIL_SEQUENCE_TO_TUPLE(__VA_ARGS__) \
  42. /**/
  43. /** \def BOOST_VMD_TO_TUPLE_D(d,...)
  44. \brief Converts a sequence to a Boost PP tuple whose elements are the elements of the sequence. Re-entrant version.
  45. d = The next available BOOST_PP_WHILE iteration. <br/>
  46. ... = Variadic parameters.
  47. The first variadic parameter is required and is the sequence to convert.
  48. Further optional variadic parameters can be return type parameters. Return type
  49. parameters allow each element in the sequence to be converted to a two-element
  50. tuple where the first tuple element is the type and the second tuple element
  51. is the element data.
  52. The BOOST_VMD_RETURN_NO_TYPE, the default, does not return the type as part of each
  53. converted element but just the data. All of the rest return the type and data as the
  54. two-element tuple. If BOOST_VMD_RETURN_TYPE is specified the specific type of the element
  55. is returned in the tuple. If BOOST_VMD_RETURN_TYPE_ARRAY is specified an array type is
  56. returned if the element is an array, else a tuple type is returned if the element is a tuple,
  57. else the actual type is returned for non-tuple data. If BOOST_VMD_RETURN_TYPE_LIST is specified
  58. a list type is returned if the element is a list, else a tuple type is returned if the element
  59. is a tuple, else the actual type is returned for non-tuple data. If BOOST_VMD_RETURN_TYPE_TUPLE
  60. is specified a tuple type is returned for all tuple-like data, else the actual type is returned
  61. for non-tuple data. If more than one return type optional parameter is specified the last one
  62. specified determines the return type.
  63. returns = A Boost PP tuple. If the sequence is empty the return is emptiness
  64. since an empty tuple does not exist. If an optional return type other
  65. than BOOST_VMD_RETURN_NO_TYPE is specified the type and the data of
  66. each element is returned as the tuple element. Otherwise just the data
  67. is returned as the tuple element, which is the default.
  68. */
  69. #define BOOST_VMD_TO_TUPLE_D(d,...) \
  70. BOOST_VMD_DETAIL_SEQUENCE_TO_TUPLE_D(d,__VA_ARGS__) \
  71. /**/
  72. #endif /* BOOST_PP_VARIADICS */
  73. #endif /* BOOST_VMD_TO_TUPLE_HPP */