Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-10-10 16:19:02


> It's a general lesson you have to learn
> about proxy objects: there's no way to make them absolutely transparent in
> C++. In particular, since they rely on an implicit conversion to translate
> the proxy into the target type, no further implicit conversions can be
> applied by the compiler. That means this won't compile with the
> optimization, though it should:
>
> int f(OtherType);
> struct OtherType {
> OtherType(const Type&);
> ...
> };
>
> Type i;
> int x = f(i++);
>
> today-is-tuesday-so-you-can't-get-something-for-nothing-ly y'rs,
>
Dang! Isn't it Wednesday somewhere....And now that you mention it, I've used
this rule to keep things from doing an unwanted implicit conversion. (It was
in one of Meyer's books, I think the first one.)

  I suppose a member template converter would make a bigger mess of things
as well right? (ambiguous conversions etc.) (Or it won't be even called
because of rule #1?)

class proxy {
public:
   template<class S>
        operator S () { return S(real) ; } // makes the copy.
...
};

  -gary-

gary.powell_at_[hidden]


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