
All, Thanks to Steven Watanabe, Ovanes Markarian, Scott Murray, Alexander Nasonov who all responded to this. The suggestions were to put it into namespace std or boost, both seem to work by the way. However what is actually right here? Extending std seems distinctly non-std ! Andy -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: 07 April 2008 20:04 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost][lexical_cast] simple example doesn't work with vector<T> AMDG Ovanes Markarian wrote:
Just an addition:
Explicit specialization of std templates is legal. So if you _exactly_ know vector types for which your <<-operator should work you can write:
namespace std { template<> ostream& operator<< (ostream& os, const vector<MyTypeX>& v) { copy(v.begin(), v.end(), ostream_iterator<T>(os, ";")); return os; } }
By the way there was a big discussion about this on std list and I fluently read the upcoming Standard draft and saw that this paragraph changed. I not any longer sure if this will be allowed with the new standard.
There has to be template to specialize. The std library doesn't have an overload of operator<< that matches std vector. Specialization can't change that. In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users