Boost logo

Boost :

Subject: Re: [boost] Extrinsec conversions
From: Vladimir Batov (batov_at_[hidden])
Date: 2009-04-01 04:24:55


> Do you think that it could be an interest in extending the C++0X
> standard to take care of these extrinsically defined conversions
> between unrelated types?

To begin with I personally do not believe there is any capacity or time to
look at extending C++0x. Already quite a few things are being re-scheduled
for a later date.

Second, I feel that in general terms conversions between "unrelated" types
can only be done on individual basis and to be addressed by making those
types "related", i.e. via Foo::Foo(Other const&) constructor or operator
Other() converter.

Another approach to generalizing conversion is only IMHO possible by
defining/relying on a certain quality that the respective classes possess.
That is, lexical_cast requires op>>() and op<<() for a class to become a
member of the "club". Therefore, I do not feel that generalizing of such
approach on the Standard level is possible.

> Have a sens to have extrinsec conversions which implicitly convert?
> Should this convert_to<T> operator be considered as a friend class of T?

I am confused. I'd think that conversions that you call "extrinsec" are
orthogonal to the participating classes and, therefore, always explicit,
i.e.

    int i = str;

will not compile when

    int i = lexical_cast<int>(str);

will. And I would not expect such conversion facility (like convert_to or
lexical_cast) to be friends to anyone as it seems intrusive.

Just my 2c.

V.


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