size.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // (C) Copyright Edward Diener 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_TUPLE_SIZE_HPP)
  6. #define BOOST_VMD_TUPLE_SIZE_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/preprocessor/control/iif.hpp>
  10. #include <boost/preprocessor/tuple/size.hpp>
  11. #include <boost/vmd/identity.hpp>
  12. #include <boost/vmd/is_empty.hpp>
  13. /*
  14. The succeeding comments in this file are in doxygen format.
  15. */
  16. /** \file
  17. */
  18. /** \def BOOST_VMD_TUPLE_SIZE(tuple)
  19. \brief expands to the size of the tuple passed to it.
  20. tuple = tuple whose size is to be extracted.
  21. If the tuple is an empty tuple its size is 0.
  22. Otherwise the result is the number of elements in the tuple.
  23. */
  24. #define BOOST_VMD_TUPLE_SIZE(tuple) \
  25. BOOST_VMD_IDENTITY_RESULT \
  26. ( \
  27. BOOST_PP_IIF \
  28. ( \
  29. BOOST_VMD_IS_EMPTY(tuple), \
  30. BOOST_VMD_IDENTITY(0), \
  31. BOOST_PP_TUPLE_SIZE \
  32. ) \
  33. (tuple) \
  34. ) \
  35. /**/
  36. #endif /* BOOST_PP_VARIADICS */
  37. #endif /* BOOST_VMD_TUPLE_SIZE_HPP */