back.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(FUSION_BACK_09162005_0350)
  7. #define FUSION_BACK_09162005_0350
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/sequence/intrinsic_fwd.hpp>
  10. #include <boost/fusion/sequence/intrinsic/end.hpp>
  11. #include <boost/fusion/iterator/prior.hpp>
  12. #include <boost/fusion/iterator/deref.hpp>
  13. #include <boost/mpl/bool.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. struct fusion_sequence_tag;
  17. namespace result_of
  18. {
  19. template <typename Sequence>
  20. struct back
  21. : result_of::deref<typename result_of::prior<typename result_of::end<Sequence>::type>::type>
  22. {};
  23. }
  24. template <typename Sequence>
  25. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  26. inline typename result_of::back<Sequence>::type
  27. back(Sequence& seq)
  28. {
  29. return *fusion::prior(fusion::end(seq));
  30. }
  31. template <typename Sequence>
  32. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  33. inline typename result_of::back<Sequence const>::type
  34. back(Sequence const& seq)
  35. {
  36. return *fusion::prior(fusion::end(seq));
  37. }
  38. }}
  39. #endif