Boost logo

Boost :

Subject: Re: [boost] Query of interest for a container output library
From: Tal Zion (talzion12_at_[hidden])
Date: 2013-01-30 10:27:22

The library defines a templated operator<< that is enabled (by
Boost.EnableIf) for all types that have a const_iterator typedef, or
evaluate to true in boost::fusion::is_sequence<T> and are not already

boost::iterator_range already defines operator<< and so the library will
"back down" and let iterator_range do its job. The library tries not to
interfere with other objects. If another object says it can be outputted to
an ostream, the library "believes" it.
By using this philosophy, the library prevents any ambiguity in operator<<.

But to answer your question, the library is completely generic and it does
support arbitrary ranges.

Here are some code snippets that show how the library captures a range:

template <typename T>
struct is_ostreamable : has_left_shift<std::ostream&amp;, T const&amp;> {};

struct sequence {
    BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_const_iterator, const_iterator,

     * Determines if a type is a sequence.
    template <typename I, typename T=typename remove_reference<I>::type >
    struct is : mpl::or_<
> {};

template <typename T>
typename boost::enable_if<
        boost::mpl::not_< // ignore everything that is ostreamable already
operator<< (std::ostream& out, T const& t) {
    return boost::stringize::detail::print(out, t);

This code may change in the future to check if T::value_type is also

View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at