Christopher Smith on 15 Aug 2003 19:40:56 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [ALACPP] correction to ostream_iterator |
On Fri, 2003-08-15 at 11:44, Jon Stewart wrote: > As to why it won't compile, it's a template function and I bet that the > lambda black magic delays type deduction, so ends can't figure out that > it's supposed to be templated off of ostream. Yeah, this is basically the problem. The lambda libraries wrap "str << _1" into a lambda functor (as the error indicates). Lambda wants type infrencing, and so does the stl (sometimes templates make it hard to be completely orthogonal ;-). Lambda is very messy in general. This will work: ostream& operator<<(ostream& str, const vector<string>& rhs) { for_each(rhs.begin(), rhs.end(), str << _1 << static_cast<ostream&(*)(ostream&)>(endl)); return str; } It will also make you sick. ;-) -- Christopher Smith <x@xxxxxxxx> _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp