#include <boost/spirit/include/karma.hpp>
#include <iostream>
#include <vector>
namespace client
{
struct counter
{
typedef int iterator;
typedef int type;
counter(int max_count)
: counter_(0), max_count_(max_count)
{}
int counter_;
int max_count_;
};
}
namespace boost { namespace spirit { namespace traits
{
template <>
struct is_container<client::counter const>
: mpl::true_
{};
template <>
struct container_iterator<client::counter const>
{
typedef client::counter::iterator type;
};
template <>
struct begin_container<client::counter const>
{
static client::counter::iterator
call(client::counter const& c)
{
return c.counter_;
}
};
template <>
struct end_container<client::counter const>
{
static client::counter::iterator
call(client::counter const& c)
{
return c.max_count_;
}
};
}}}
namespace boost { namespace spirit { namespace traits
{
template <>
struct deref_iterator<client::counter::iterator>
{
typedef client::counter::type type;
static type call(client::counter::iterator const& it)
{
return it;
}
};
}}}
namespace karma = boost::spirit::karma;
int main()
{
client::counter count(4);
std::cout << karma::format(karma::int_ % ", ", count) << std::endl; return 0;
}