Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-06-30 06:57:05


klaus triendl wrote:

[...]

> MyStream& operator <<(MyStream& os, const int&)
> {
> return os;
> }
>
> int main()
> {
> list<shared_ptr<int> > 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net