]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/sequence/intrinsic/end.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / sequence / intrinsic / end.hpp
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_END_04052005_1141)
8 #define FUSION_END_04052005_1141
9
10 #include <boost/blank.hpp>
11 #include <boost/utility/enable_if.hpp>
12 #include <boost/mpl/if.hpp>
13 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
14 #include <boost/fusion/support/tag_of.hpp>
15 #include <boost/fusion/support/is_sequence.hpp>
16 #include <boost/fusion/support/is_segmented.hpp>
17 #include <boost/fusion/sequence/intrinsic/detail/segmented_end.hpp>
18
19 namespace boost { namespace fusion
20 {
21     // Special tags:
22     struct sequence_facade_tag;
23     struct boost_tuple_tag; // boost::tuples::tuple tag
24     struct boost_array_tag; // boost::array tag
25     struct mpl_sequence_tag; // mpl sequence tag
26     struct std_pair_tag; // std::pair tag
27
28     namespace extension
29     {
30         template <typename Tag>
31         struct end_impl
32         {
33             template <typename Sequence>
34             struct apply
35               : mpl::if_<
36                     traits::is_segmented<Sequence>
37                   , detail::segmented_end<Sequence>
38                   , blank
39                 >::type
40             {};
41         };
42
43         template <>
44         struct end_impl<sequence_facade_tag>
45         {
46             template <typename Sequence>
47             struct apply : Sequence::template end<Sequence> {};
48         };
49
50         template <>
51         struct end_impl<boost_tuple_tag>;
52
53         template <>
54         struct end_impl<boost_array_tag>;
55
56         template <>
57         struct end_impl<mpl_sequence_tag>;
58
59         template <>
60         struct end_impl<std_pair_tag>;
61     }
62
63     namespace result_of
64     {
65         template <typename Sequence>
66         struct end
67             : extension::end_impl<typename detail::tag_of<Sequence>::type>::
68                 template apply<Sequence>
69         {};
70     }
71
72     template <typename Sequence>
73     inline typename
74         lazy_enable_if<
75             traits::is_sequence<Sequence>
76           , result_of::end<Sequence>
77         >::type const
78     end(Sequence& seq)
79     {
80         return result_of::end<Sequence>::call(seq);
81     }
82
83     template <typename Sequence>
84     inline typename
85         lazy_enable_if<
86             traits::is_sequence<Sequence>
87           , result_of::end<Sequence const>
88         >::type const
89     end(Sequence const& seq)
90     {
91         return result_of::end<Sequence const>::call(seq);
92     }
93 }}
94
95 #endif