Boost logo

Boost :

From: Bjorn.Karlsson_at_[hidden]
Date: 2002-05-08 02:07:24


> From: Darin Adler [mailto:darin_at_[hidden]]
>
> Some people have developed a "safe_bool" idiom where you
> define a conversion to an obscure type of pointer (a
> particularly obscure variant of a pointer to a member) so you
> can do "if (p)" statements, but not "int i = p" statements.
> It's used in the Boost function library.
>
> We might want to consider using this technique in the smart
> pointer library. It's inelegant in implementation, but a lot
> of people like the "if (p)" idiom.
>
> -- Darin

I've noticed that the current version in the CVS does exactly this. It's
really neat, as it enables a very useful idiom without sacrificing safety.

Bjorn



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk