
klaus triendl wrote: [...]
MyStream& operator <<(MyStream& os, const int&) { return os; }
int main() { list
cont; MyStream osTop; MySubStream osSub(&osTop);
MyStream& tmp = osSub;
for_each(cont.begin(), cont.end(), ref(osSub) << *_1);
for_each( cont.begin(), cont.end(), tmp << *_1 ); // or, if the above doesn't work - it should - for_each( cont.begin(), cont.end(), ref(tmp) << *_1 );
return 0; } ----
g++ outputs error: '/usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:212: error: conversion from 'MyStream' to non-scalar type 'MySubStream' requested'.
Lambda sees that you are invoking operator<< on a MySubStream& and deduces the return type to be MySubStream&; it isn't smart enough to see that you're actually using the operator<< definition for the base class MyStream.