File indexing completed on 2025-01-18 09:30:26
0001
0002 #ifndef BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL_HPP_
0003 #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL_HPP_
0004
0005
0006
0007
0008
0009
0010 #include <boost/contract/detail/name.hpp>
0011 #include <boost/config.hpp>
0012 #include <boost/detail/workaround.hpp>
0013
0014
0015
0016
0017
0018
0019 #define BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) \
0020 bool operator!() const BOOST_NOEXCEPT { return !(bool_expr); }
0021
0022
0023
0024 #if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) && \
0025 !defined(BOOST_NO_CXX11_NULLPTR)
0026 #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
0027 explicit operator bool() const BOOST_NOEXCEPT { return (bool_expr); } \
0028 BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
0029 #elif (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || \
0030 defined(__CINT__)
0031 #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
0032 operator bool() const BOOST_NOEXCEPT { return (bool_expr); } \
0033 BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
0034 #elif defined(_MANAGED)
0035 #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
0036 static void BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func)( \
0037 this_type***) {} \
0038 typedef void (*BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type))( \
0039 this_type***); \
0040 operator BOOST_CONTRACT_DETAIL_NANE(operator_safe_bool_type)() \
0041 const BOOST_NOEXCEPT { \
0042 return (bool_expr) ? \
0043 &BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func) : 0; \
0044 } \
0045 BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
0046 #elif (defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200)) || \
0047 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304)) || \
0048 (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590))
0049 #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
0050 void BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func)() const {} \
0051 typedef void (this_type::*BOOST_CONTRACT_DETAIL_NAME1( \
0052 operator_safe_bool_type))() const; \
0053 operator BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type)() \
0054 const BOOST_NOEXCEPT { \
0055 return (bool_expr) ? &this_type:: \
0056 BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func) : 0; \
0057 } \
0058 BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
0059 #else
0060 #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
0061 void* BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_data); \
0062 typedef void* this_type::*BOOST_CONTRACT_DETAIL_NAME1( \
0063 operator_safe_bool_type);\
0064 operator BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type)() \
0065 const BOOST_NOEXCEPT { \
0066 return (bool_expr) ? &this_type:: \
0067 BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_data) : 0; \
0068 } \
0069 BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
0070 #endif
0071
0072 #endif
0073