Boost logo

Boost :

Subject: Re: [boost] Implicit cast rules
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2011-05-24 09:53:24


On Tue, May 24, 2011 at 1:41 PM, Krzysztof Czainski <1czajnik_at_[hidden]>wrote:

>
> The compiler sais "cannot convert 'const C' to 'int'. I think it means
> static_cast<> takes c as a const, and your conversion operator is not a
> const member, so the compiler cannot use it. Solution (not tested):
>
> operator optional<int>() const { return none; }
>
>
That doesn't work either, nor does

cout << ( optional<int> ) c << endl;

but this does

cout << c.operator optional<int>( ) << endl;

But I guess that's not really what you're looking for.

HTH

- Rob.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk