]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/sequence/io/detail/out.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / sequence / io / detail / out.hpp
1 /*=============================================================================
2     Copyright (c) 1999-2003 Jaakko Jarvi
3     Copyright (c) 1999-2003 Jeremiah Willcock
4     Copyright (c) 2001-2011 Joel de Guzman
5
6     Distributed under the Boost Software License, Version 1.0. (See accompanying 
7     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #if !defined(FUSION_OUT_05052005_0121)
10 #define FUSION_OUT_05052005_0121
11
12 #include <ostream>
13 #include <boost/fusion/sequence/io/detail/manip.hpp>
14
15 #include <boost/mpl/bool.hpp>
16 #include <boost/fusion/sequence/intrinsic/begin.hpp>
17 #include <boost/fusion/sequence/intrinsic/end.hpp>
18 #include <boost/fusion/iterator/deref.hpp>
19 #include <boost/fusion/iterator/next.hpp>
20 #include <boost/fusion/iterator/equal_to.hpp>
21
22 namespace boost { namespace fusion { namespace detail
23 {
24     template <typename Tag>
25     struct delimiter_out
26     {
27         // print a delimiter
28         template <typename OS>
29         static void
30         print(OS& os, char const* delim, mpl::false_ = mpl::false_())
31         {
32             detail::string_ios_manip<Tag, OS> manip(os);
33             manip.print(delim);
34         }
35
36         template <typename OS>
37         static void
38         print(OS&, char const*, mpl::true_)
39         {
40         }
41     };
42
43     struct print_sequence_loop
44     {
45         template <typename OS, typename First, typename Last>
46         static void
47         call(OS&, First const&, Last const&, mpl::true_)
48         {
49         }
50
51         template <typename OS, typename First, typename Last>
52         static void
53         call(OS& os, First const& first, Last const& last, mpl::false_)
54         {
55             result_of::equal_to<
56                 typename result_of::next<First>::type
57               , Last
58             >
59             is_last;
60
61             os << *first;
62             delimiter_out<tuple_delimiter_tag>::print(os, " ", is_last);
63             call(os, fusion::next(first), last, is_last);
64         }
65
66         template <typename OS, typename First, typename Last>
67         static void
68         call(OS& os, First const& first, Last const& last)
69         {
70             result_of::equal_to<First, Last> eq;
71             call(os, first, last, eq);
72         }
73     };
74
75     template <typename OS, typename Sequence>
76     inline void
77     print_sequence(OS& os, Sequence const& seq)
78     {
79         delimiter_out<tuple_open_tag>::print(os, "(");
80         print_sequence_loop::call(os, fusion::begin(seq), fusion::end(seq));
81         delimiter_out<tuple_close_tag>::print(os, ")");
82     }
83 }}}
84
85 #endif