push_front.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_TUPLE_PUSH_FRONT_HPP)
  6. #define BOOST_VMD_TUPLE_PUSH_FRONT_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/push_front.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_PUSH_FRONT(tuple,elem)
  19. \brief inserts an element at the beginning of a tuple.
  20. tuple = tuple to insert an element at. <br/>
  21. elem = element to insert.
  22. If the tuple is an empty tuple the result is a tuple with the single element.
  23. Otherwise the result is a tuple after inserting the element at the beginning.
  24. */
  25. #define BOOST_VMD_TUPLE_PUSH_FRONT(tuple,elem) \
  26. BOOST_VMD_IDENTITY_RESULT \
  27. ( \
  28. BOOST_PP_IIF \
  29. ( \
  30. BOOST_VMD_IS_EMPTY(tuple), \
  31. BOOST_VMD_IDENTITY((elem)), \
  32. BOOST_PP_TUPLE_PUSH_FRONT \
  33. ) \
  34. (tuple,elem) \
  35. ) \
  36. /**/
  37. #endif /* BOOST_PP_VARIADICS */
  38. #endif /* BOOST_VMD_TUPLE_PUSH_FRONT_HPP */