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