]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/container/list/detail/reverse_cons.hpp
5083e0c0d115b212e509b03cbd09216e89774ac3
[rsem.git] / boost / fusion / container / list / detail / reverse_cons.hpp
1 /*=============================================================================
2     Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_REVERSE_CONS_HPP_INCLUDED)
8 #define BOOST_FUSION_REVERSE_CONS_HPP_INCLUDED
9
10 #include <boost/fusion/container/list/cons_fwd.hpp>
11
12 namespace boost { namespace fusion { namespace detail
13 {
14     ////////////////////////////////////////////////////////////////////////////
15     template<typename Cons, typename State = nil_>
16     struct reverse_cons;
17
18     template<typename Car, typename Cdr, typename State>
19     struct reverse_cons<cons<Car, Cdr>, State>
20     {
21         typedef reverse_cons<Cdr, cons<Car, State> > impl;
22         typedef typename impl::type type;
23
24         static type call(cons<Car, Cdr> const &cons, State const &state = State())
25         {
26             typedef fusion::cons<Car, State> cdr_type;
27             return impl::call(cons.cdr, cdr_type(cons.car, state));
28         }
29     };
30
31     template<typename State>
32     struct reverse_cons<nil_, State>
33     {
34         typedef State type;
35
36         static State const &call(nil_ const &, State const &state = State())
37         {
38             return state;
39         }
40     };
41 }}}
42
43 #endif