push_back.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_PUSH_BACK_HPP)
  6. #define BOOST_VMD_SEQ_PUSH_BACK_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/preprocessor/control/iif.hpp>
  10. #include <boost/preprocessor/seq/push_back.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_SEQ_PUSH_BACK(seq,elem)
  19. \brief appends an element to the end of a seq.
  20. seq = seq to to append an element to. <br/>
  21. elem = element to append.
  22. If the seq is an empty seq the result is a seq with the single element.
  23. Otherwise the result is a seq after adding the element to the end.
  24. */
  25. #define BOOST_VMD_SEQ_PUSH_BACK(seq,elem) \
  26. BOOST_VMD_IDENTITY_RESULT \
  27. ( \
  28. BOOST_PP_IIF \
  29. ( \
  30. BOOST_VMD_IS_EMPTY(seq), \
  31. BOOST_VMD_IDENTITY((elem)), \
  32. BOOST_PP_SEQ_PUSH_BACK \
  33. ) \
  34. (seq,elem) \
  35. ) \
  36. /**/
  37. #endif /* BOOST_PP_VARIADICS */
  38. #endif /* BOOST_VMD_SEQ_PUSH_BACK_HPP */