is_empty_array.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_IS_EMPTY_ARRAY_HPP)
  6. #define BOOST_VMD_IS_EMPTY_ARRAY_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/preprocessor/control/iif.hpp>
  10. #include <boost/vmd/is_array.hpp>
  11. #include <boost/vmd/identity.hpp>
  12. #include <boost/vmd/detail/is_empty_array.hpp>
  13. /*
  14. The succeeding comments in this file are in doxygen format.
  15. */
  16. /** \file
  17. */
  18. /** \def BOOST_VMD_IS_EMPTY_ARRAY(sequence)
  19. \brief Tests whether a sequence is an empty Boost PP array.
  20. An empty Boost PP array is a two element tuple where the first
  21. size element is 0 and the second element is a tuple with a single
  22. empty element, ie. '(0,())'.
  23. sequence = a possible empty array
  24. returns = 1 if the sequence is an empty Boost PP array,
  25. 0 if it is not.
  26. The macro will generate a preprocessing error if the sequence
  27. is in the form of an array but its first tuple element, instead
  28. of being a number, is a preprocessor token which VMD cannot parse,
  29. as in the example '(&0,())' which is a valid tuple but an invalid
  30. array.
  31. */
  32. #define BOOST_VMD_IS_EMPTY_ARRAY(sequence) \
  33. BOOST_VMD_IDENTITY_RESULT \
  34. ( \
  35. BOOST_PP_IIF \
  36. ( \
  37. BOOST_VMD_IS_ARRAY(sequence), \
  38. BOOST_VMD_DETAIL_IS_EMPTY_ARRAY_SIZE, \
  39. BOOST_VMD_IDENTITY(0) \
  40. ) \
  41. (sequence) \
  42. ) \
  43. /**/
  44. /** \def BOOST_VMD_IS_EMPTY_ARRAY_D(d,sequence)
  45. \brief Tests whether a sequence is an empty Boost PP array. Re-entrant version.
  46. An empty Boost PP array is a two element tuple where the first
  47. size element is 0 and the second element is a tuple with a single
  48. empty element, ie. '(0,())'.
  49. d = The next available BOOST_PP_WHILE iteration. <br/>
  50. sequence = a possible empty array
  51. returns = 1 if the sequence is an empty Boost PP array,
  52. 0 if it is not.
  53. The macro will generate a preprocessing error if the sequence
  54. is in the form of an array but its first tuple element, instead
  55. of being a number, is a preprocessor token which VMD cannot parse,
  56. as in the example '(&0,())' which is a valid tuple but an invalid
  57. array.
  58. */
  59. #define BOOST_VMD_IS_EMPTY_ARRAY_D(d,sequence) \
  60. BOOST_VMD_IDENTITY_RESULT \
  61. ( \
  62. BOOST_PP_IIF \
  63. ( \
  64. BOOST_VMD_IS_ARRAY_D(d,sequence), \
  65. BOOST_VMD_DETAIL_IS_EMPTY_ARRAY_SIZE, \
  66. BOOST_VMD_IDENTITY(0) \
  67. ) \
  68. (sequence) \
  69. ) \
  70. /**/
  71. #endif /* BOOST_PP_VARIADICS */
  72. #endif /* BOOST_VMD_IS_EMPTY_ARRAY_HPP */