Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-09-06 09:10:48

Douglas Gregor wrote:
> On Friday 05 September 2003 02:43 pm, Ed Brey wrote:
>>3. It avoids inefficiencies that other approaches impose. For instance,
>>when I examine the optimized code generated by VC 7.1 from the technique
>>used by shared_ptr et al, I find code that does a run-time fetch of the
>>"unspecified" member address from a non-immediate variable. Another way to
>>put it is that for shared_ptr, these two fragments generate different code:
>>if (ptr.get()) ...
>>if (ptr) ... // Less efficient.

Given that this is true...

> IMHO, this is something we should document, not code around. If we can't get
> the optimization without losing something (and we did lose something; see
> above), we probably shouldn't do it because there is an easy workaround.

Maybe we should consider using the technique I used for bool_testable
instead of Peter's safe-bool-idiom, as IMHO efficiency is more important
than a nice error message. Comments? Peter?

Regards, Daniel

Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web:

Boost list run by bdawes at, gregod at, cpdaniel at, john at