remove.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_SEQ_REMOVE_HPP)
  6. #define BOOST_VMD_SEQ_REMOVE_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/logical/bitand.hpp>
  12. #include <boost/preprocessor/seq/remove.hpp>
  13. #include <boost/preprocessor/seq/size.hpp>
  14. #include <boost/vmd/empty.hpp>
  15. /*
  16. The succeeding comments in this file are in doxygen format.
  17. */
  18. /** \file
  19. */
  20. /** \def BOOST_VMD_SEQ_REMOVE(seq,index)
  21. \brief removes an element from a seq.
  22. seq = seq from which an element is to be removed. <br/>
  23. index = The zero-based position in seq of the element to be removed.
  24. If index is greater or equal to the seq size the result is undefined.
  25. If the seq is a single element and the index is 0 the result is an empty seq.
  26. Otherwise the result is a seq after removing the index element.
  27. */
  28. #define BOOST_VMD_SEQ_REMOVE(seq,index) \
  29. BOOST_PP_IIF \
  30. ( \
  31. BOOST_PP_BITAND \
  32. ( \
  33. BOOST_PP_EQUAL(index,0), \
  34. BOOST_PP_EQUAL(BOOST_PP_SEQ_SIZE(seq),1) \
  35. ), \
  36. BOOST_VMD_EMPTY, \
  37. BOOST_PP_SEQ_REMOVE \
  38. ) \
  39. (seq,index) \
  40. /**/
  41. #endif /* BOOST_PP_VARIADICS */
  42. #endif /* BOOST_VMD_SEQ_REMOVE_HPP */