2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 16:52:10 +00:00
Files
spirit/test/karma/format_pointer_container.cpp
Nikita Kniazev f44479bcd3 Remove boost/config/warning_disable.hpp usage
It is better to manage warnings on our side to know what warnings we need to fix or suppress, and the only thing that header does is disabling deprecation warnings on MSVC and ICC which we would prefer to not show to users.
2021-08-24 03:14:12 +03:00

59 lines
1.3 KiB
C++

// Copyright (c) 2009 Matthias Vallentin
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/core/lightweight_test.hpp>
#include <boost/iterator/indirect_iterator.hpp>
#include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/karma_format.hpp>
#include <sstream>
#include <string>
#include <vector>
struct foo : boost::noncopyable
{
foo()
: str("foo")
{
}
std::string str;
};
template <typename Stream>
Stream& operator<<(Stream& out, const foo& f)
{
out << f.str;
return out;
}
int main()
{
using namespace boost::spirit;
typedef boost::shared_ptr<foo> foo_ptr;
std::vector<foo_ptr> v;
std::size_t i = 10;
while (i--)
v.push_back(boost::make_shared<foo>());
typedef boost::indirect_iterator<std::vector<foo_ptr>::const_iterator>
iterator_type;
std::stringstream strm;
strm
<< karma::format(stream % ',',
boost::iterator_range<iterator_type>(
iterator_type(v.begin()), iterator_type(v.end())
)
);
BOOST_TEST(strm.str() == "foo,foo,foo,foo,foo,foo,foo,foo,foo,foo");
return boost::report_errors();
}