>From: "Glenn G. Chappell" <[EMAIL PROTECTED]>

> Vladimir Prus wrote:
> > after having to output std::vector to stream again and again using
> > custom
> > solution, I started to wonder why we don't have a solution in boost.
> > Does it makes sense to include operators<< for vectors, sets, etc?
> ...
> >     std::cout << "new path is " << v << "\n";
>
> The philosophy behind the STL would suggest accessing containers
> through their iterators. Something like
>
> std::cout << "new path is "
>           << Foo(v.begin(), v.end())
>           << "\n";
>
> would not be too bad (and it would be even better if it were called
> something besides "Foo"). This would be very general, while
> remaining quite readble, I think.
>
> Delimiters could be set using optional parameters, among other
> methods.
>
> std::cout << "new path is "
>           << Foo(v.begin(), v.end(), "[", ",", "]")
>           << "\n";

You then still have the issue of what to do with the element types. For
example:

std::vector<std::pair<char,int> > v;

std::cout << Foo(v.begin(),v.end(),"[",",","]") << '\n';

How to print each element, and what if you want different delimiters for the
elements?


Regards,

Terje

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to