Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-01-12 19:52:03


At 04:05 PM 1/12/2001 -0500, George A. Heintzelman wrote:
> ...
>> Yes, but I don't really see any problems with it, other than the
>> efficiency issue with certain bigint types. In cases where the
>> efficiency is a real issue, the template constructor can be by-passed
>> by using an explicit cast to IntType.
>
>This is where you need an implicit_cast template:
>
>template <class ToClass, class FromClass>
>ToClass implicit_cast(const FromClass &casted_object)
> { return casted_object; }
>
>which will not compile unless there is an implicit conversion from
>FromClass to ToClass. Then the constructor becomes:
>
>template <class T> rational(T n) :
> num(boost::implicit_cast<IntType>(n)),
> den(IntType(1)) {} // Or whatever you finally decide to use for 1.
>
>I seem to remember some discussion about exactly this sort of need, and
>had thought that it was in the BCL, but it doesn't seem to be. Perhaps
>this is an example which suggests it needs to be added?

We removed implicit_cast<> because it had a number of problems. The
comment in the header says:

// Removed due to uncertain purpose. Use either numeric_cast (see below)
// or static_cast according to the need.

Best,

--Beman


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