]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/karma/regression_iterator.cpp
1 // Copyright (c) 2013 Louis Dionne
2 // Copyright (c) 2001-2013 Hartmut Kaiser
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)
7 #include <boost/config/warning_disable.hpp>
8 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/range/adaptor/transformed.hpp>
11 #include <boost/spirit/include/karma.hpp>
15 // Note how the return is made by value instead of by reference.
16 template <typename T
> T
identity(T
const& t
) { return t
; }
18 template <typename Char
, typename Expr
, typename CopyExpr
, typename CopyAttr
19 , typename Delimiter
, typename Attribute
>
20 bool test(Char
const *expected
,
21 boost::spirit::karma::detail::format_manip
<
22 Expr
, CopyExpr
, CopyAttr
, Delimiter
, Attribute
> const& fm
)
24 std::ostringstream ostrm
;
26 return ostrm
.good() && ostrm
.str() == expected
;
31 namespace karma
= boost::spirit::karma
;
32 namespace adaptors
= boost::adaptors
;
33 int ints
[] = {0, 1, 2, 3, 4};
35 BOOST_TEST((test("0 1 2 3 4",
36 karma::format(karma::int_
% ' ',
37 ints
| adaptors::transformed(&identity
<int>)))
40 return boost::report_errors();