Boost logo

Geometry :

Subject: [ggl] user controllable numeric conversion.
From: Barend Gehrels (barend.gehrels)
Date: 2010-05-04 11:58:26


Hi again,

>
>
>> What about use macro to switch between numeric_cast and implicit
>> conversion?
>>
>> for example:
>>
>> #ifdef USE_IMPLICIT_CONVERSION
>> # define NUMERIC_CAST(TargetType, Source) Source
>> #else
>> # define NUMERIC_CAST(TargetType, Source)
>> ::boost::numeric_cast<TargetType>(Source)
>> #endif
>>
>> then, in the code:
>> t = NUMERIC_CAST((target type here), (Source value here));
>>
>> Using numeric_cast as default can make the complier output neat and
>> tidy. It should also work smoothly for common use.
>> User can define USE_IMPLICIT_CONVERSION when they don't want
>> numeric_cast.
>
> Besides that I don't like macro's, this might be useful to enable both
> options.
>
Without a macro it should also be possible using an inline function
(still within defines), e.g. boost::geometry::numeric_cast<> forwarding
to boost::numeric_cast (or just assigning)

B.


Geometry list run by mateusz at loskot.net