
Message du 06/05/11 00:07 De : "John Bytheway" A : boost@lists.boost.org Copie à : Objet : Re: [boost] std::map::find() wrapper
On 05/05/11 22:55, Vicente BOTET wrote:
Message du 05/05/11 23:50 De : "John Bytheway" A : boost@lists.boost.org Copie à : Objet : Re: [boost] std::map::find() wrapper
The compiler doesn't have to do a null-check for the reference case, so it's shorter.
I would be interested in knowing why the compiler need to check for 0 when you apply a static_cast?
Because static_cast(b) is valid when b == 0, and must return 0, but any non-zero value must be changed (by subtracting 4) because of the multiple inheritance. This is a pretty obscure corner case, but it does demonstrate that the non-NULL guarantee for references has at least some performance implications.
Thanks, I miss the multiple inheritance. Best, Vicente