
Giovanni Palma <giovanni@lrde.epita.fr> writes:
Index: integre/ChangeLog from Giovanni Palma <giovanni@lrde.epita.fr>
* ntg/utils/cast.hh: Make force use a single cast instead of delegate its work to an unsafe type.
[...]
Index: integre/ntg/utils/cast.hh --- integre/ntg/utils/cast.hh Thu, 27 Nov 2003 11:26:27 +0100 burrus_n (oln/i/26_cast.hh 1.3.1.11 640) +++ integre/ntg/utils/cast.hh Wed, 28 Jan 2004 16:22:43 +0100 palma_g (oln/i/26_cast.hh 1.3.1.11 640) @@ -70,12 +70,14 @@ | force | `------*/
+ // a cast is performed instead of a constructor (unsafe one) call + // because this last one may not be available with the good + // signature. template<class Tdest, class Tsrc> inline const Tdest force(const Tsrc& val) { - ntg_unsafe_type(Tdest) tmp (val); - return tmp; + return (Tdest)val; }
Ce code pose pb dans quels cas ? Le pb en enlevant le passage par un type unsafe, c'est qu il peut y avoir un check dynamique. L interet de cast::force est justement d assurer qu aucune verification ne sera faite. Si ce n'est pas le cas, autant utiliser directement le cast habituel sans passer par cast::force.