Subject: [ggl] user controllable numeric conversion.
Date: 2010-04-29 03:52:49
I saw lots of numeric_cast spread around to perform numeric conversion
between different coordinate type.
numeric_cast is not so "general" for general programming (while the
numeric::converter is). Although, user can still make their own coordinate
type (UDT) to be available to numeric_cast, but the other traits of
numeric::converter are fixed. And for built-in type conversion, it is
totally out of user's control.
It is ok to put numeric_cast in interface for convenience. A more general
way would add another interface with a numeric converter parameter. But that
could be too troublesome for both user and developer.
So my suggestion here would be
1. use numeric_cast in a limited range, be sure that would not bypass user's
2. user should be notified not to mix using of different coordinate type
that could be ill-formed(in the documentation).
3. If user wants to use their own numeric converter, they should explicitly
use the transform algorithm. To make it simple, make
transform_strategy::apply() accepts another numeric converter parameter, and
also add two interfaces of transform algorithm to accept converter parameter
which would be passed to transform_strategy::apply(). The two original
transform interfaces can be applied with numeric_cast as default converter.
If it would result problem in current code, at least make another
copy_per_coordinate like strategy that can be explicitly constructed from a
numeric converter which would be used in apply(). Such strategy would be
dedicated for coordinate type conversion, but is less convenient than the
-- View this message in context: http://boost-geometry.203548.n3.nabble.com/user-controllable-numeric-conversion-tp764660p764660.html Sent from the Boost Geometry mailing list archive at Nabble.com.
Geometry list run by mateusz at loskot.net