pop_back.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_POP_BACK_HPP)
  6. #define BOOST_VMD_TUPLE_POP_BACK_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/preprocessor/comparison/equal.hpp>
  10. #include <boost/preprocessor/control/iif.hpp>
  11. #include <boost/preprocessor/tuple/pop_back.hpp>
  12. #include <boost/preprocessor/tuple/size.hpp>
  13. #include <boost/vmd/empty.hpp>
  14. /*
  15. The succeeding comments in this file are in doxygen format.
  16. */
  17. /** \file
  18. */
  19. /** \def BOOST_VMD_TUPLE_POP_BACK(tuple)
  20. \brief pops an element from the end of a tuple.
  21. tuple = tuple to pop an element from.
  22. If the tuple is an empty tuple the result is undefined.
  23. If the tuple is a single element the result is an empty tuple.
  24. Otherwise the result is a tuple after removing the last element.
  25. */
  26. #define BOOST_VMD_TUPLE_POP_BACK(tuple) \
  27. BOOST_PP_IIF \
  28. ( \
  29. BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \
  30. BOOST_VMD_EMPTY, \
  31. BOOST_PP_TUPLE_POP_BACK \
  32. ) \
  33. (tuple) \
  34. /**/
  35. /** \def BOOST_VMD_TUPLE_POP_BACK_Z(z,tuple)
  36. \brief pops an element from the end of a tuple. It reenters BOOST_PP_REPEAT with maximum efficiency.
  37. z = the next available BOOST_PP_REPEAT dimension.
  38. tuple = tuple to pop an element from.
  39. If the tuple is an empty tuple the result is undefined.
  40. If the tuple is a single element the result is an empty tuple.
  41. Otherwise the result is a tuple after removing the last element.
  42. */
  43. #define BOOST_VMD_TUPLE_POP_BACK_Z(z,tuple) \
  44. BOOST_PP_IIF \
  45. ( \
  46. BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \
  47. BOOST_VMD_EMPTY, \
  48. BOOST_PP_TUPLE_POP_BACK_Z \
  49. ) \
  50. (z,tuple) \
  51. /**/
  52. #endif /* BOOST_PP_VARIADICS */
  53. #endif /* BOOST_VMD_TUPLE_POP_BACK_HPP */