|
Boost : |
Subject: Re: [boost] safe-bool CRTP class
From: Bryce Lelbach (blelbach_at_[hidden])
Date: 2011-05-27 16:42:19
Such a class is already in Boost, in two places:
/home/wash/development/boost-trunk-wc/boost/range/detail/safe_bool.hpp
/home/wash/development/boost-trunk-wc/boost/spirit/core/safe_bool.hpp
/home/wash/development/boost-trunk-wc/boost/spirit/home/classic/core/safe_bool.hpp
/home/wash/development/boost-trunk-wc/boost/spirit/include/classic_safe_bool.hpp
smart_ptr also has a version.
Attached is a modified version of this that incorporates portability code from
the smart_ptr version into the variant of the spirit safe_bool that Hartmut and
I use at work.
I like to have a macro for this, so I have an operator that's convertible to the
safe_bool class, which is itself convertible to bool (this avoids problem with
the need for "typename" in the macro in certain contexts). The safe_bool class
is itself convertible to bool.
Feel free to incorporate any of this code into whatever comes out of this thread.
-- Bryce Lelbach aka wash boost-spirit.com px.cct.lsu.edu github.com/lll-project
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk