Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2005-05-10 12:54:49


"Sam Partington" wrote:

>> > 6. The exists(), is_null() and operator bool() methods fall prey to a
>> > well known C++ pitfall. Have a look at Bjorn Karlsson's article, "The
>> > Safe Bool Idiom": http://www.artima.com/cppsource/safebool.html.
>> >
>> Looks so. It would be nice to have a common support for this
>> in Boost, though.
>
> I suggested this as an addition to the operators library sometime ago,
> and patches to the code/docs/tests were applied, but they were later
> removed. I'll to summarise why.
>
> The first suggestion, which was based on Peters pointer to member
> function conversion :
> http://lists.boost.org/MailArchives/boost/msg44416.php
> (the patches)
> http://lists.boost.org/MailArchives/boost/msg44529.php
>
> But then Daniel Frey found a problem with the implementation for
> classes with integral conversion operators of their own. The integral
> conversion operator was a better match and so the safe-bool conversion
> was never called :
>
> http://lists.boost.org/MailArchives/boost/msg44894.php
>
> So then we tried an implementation based on using a private integral
> conversion operator and a public operator bool :
>
> http://lists.boost.org/MailArchives/boost/msg45089.php
>
> This worked well in itself, but caused problems with the type traits
> is_convertible (sorry, don't seem to be able to find a link to any of
> those messages).
>
> Finally the whole topic was dropped after a long thread, and the code
> was removed from the CVS tree. A shame I think though, as there were
> still several open designs which had possiblities. The end of the
> discussion is here :
>
> http://aspn.activestate.com/ASPN/Mail/Message/boost/1900317
>
> I'd like to see the solution back in boost, we've been using it here
> for a couple of years now without problems, and we find it very
> useful. I'd be willing to put more work into it if there is interest.
>
Reads like a story.

Small utilities don't always get handled in the best way.
Perhaps you may propose your as new library (which just happens
not to add new files). It would take long but at least this process
has clear resolution at the end.

/Pavel


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