Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:59

0001 /*=============================================================================
0002     Copyright (c) 2003 Joel de Guzman
0003     http://spirit.sourceforge.net/
0004 
0005   Distributed under the Boost Software License, Version 1.0. (See accompanying
0006   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #if !defined(BOOST_SPIRIT_SAFE_BOOL_HPP)
0009 #define BOOST_SPIRIT_SAFE_BOOL_HPP
0010 
0011 #include <boost/config.hpp>
0012 #include <boost/detail/workaround.hpp>
0013 #include <boost/spirit/home/classic/namespace.hpp>
0014 
0015 namespace boost { namespace spirit {
0016 
0017 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0018 
0019     namespace impl
0020     {
0021         template <typename T>
0022         struct no_base {};
0023 
0024         template <typename T>
0025         struct safe_bool_impl
0026         {
0027 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
0028             void stub(T*) {};
0029             typedef void (safe_bool_impl::*type)(T*);
0030 #else
0031             typedef T* TP; // workaround to make parsing easier
0032             TP stub;
0033             typedef TP safe_bool_impl::*type;
0034 #endif
0035         };
0036     }
0037 
0038     template <typename DerivedT, typename BaseT = impl::no_base<DerivedT> >
0039     struct safe_bool : BaseT
0040     {
0041     private:
0042         typedef impl::safe_bool_impl<DerivedT> impl_t;
0043         typedef typename impl_t::type bool_type;
0044 
0045     public:
0046         operator bool_type() const
0047         {
0048             return static_cast<const DerivedT*>(this)->operator_bool() ?
0049                 &impl_t::stub : 0;
0050         }
0051 
0052         operator bool_type()
0053         {
0054             return static_cast<DerivedT*>(this)->operator_bool() ?
0055                 &impl_t::stub : 0;
0056         }
0057     };
0058 
0059 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0060 
0061 }}
0062 
0063 #endif
0064