explicit_operator_bool.hpp
Go to the documentation of this file.
1 /*
2  * Copyright Andrey Semashev 2007 - 2013.
3  * Distributed under the Boost Software License, Version 1.0.
4  * (See accompanying file LICENSE_1_0.txt or copy at
5  * http://www.boost.org/LICENSE_1_0.txt)
6  */
7 
18 #ifndef BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP
19 #define BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP
20 
21 #include <boost/config.hpp>
22 
23 #ifdef BOOST_HAS_PRAGMA_ONCE
24 #pragma once
25 #endif
26 
27 #if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
28 
36 #define BOOST_EXPLICIT_OPERATOR_BOOL()\
37  BOOST_FORCEINLINE explicit operator bool () const\
38  {\
39  return !this->operator! ();\
40  }
41 
49 #define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\
50  BOOST_FORCEINLINE explicit operator bool () const BOOST_NOEXCEPT\
51  {\
52  return !this->operator! ();\
53  }
54 
62 #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\
63  BOOST_FORCEINLINE BOOST_CONSTEXPR explicit operator bool () const BOOST_NOEXCEPT\
64  {\
65  return !this->operator! ();\
66  }
67 
68 #else // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
69 
70 #if (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG)
71 // Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it
72 #define BOOST_NO_UNSPECIFIED_BOOL
73 #endif // (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG)
74 
75 #if !defined(BOOST_NO_UNSPECIFIED_BOOL)
76 
77 namespace boost {
78 
79 namespace detail {
80 
81 #if !defined(_MSC_VER) && !defined(__IBMCPP__)
82 
83  struct unspecified_bool
84  {
85  // NOTE TO THE USER: If you see this in error messages then you tried
86  // to apply an unsupported operator on the object that supports
87  // explicit conversion to bool.
88  struct OPERATORS_NOT_ALLOWED;
89  static void true_value(OPERATORS_NOT_ALLOWED*) {}
90  };
91  typedef void (*unspecified_bool_type)(unspecified_bool::OPERATORS_NOT_ALLOWED*);
92 
93 #else
94 
95  // MSVC and VACPP are too eager to convert pointer to function to void* even though they shouldn't
96  struct unspecified_bool
97  {
98  // NOTE TO THE USER: If you see this in error messages then you tried
99  // to apply an unsupported operator on the object that supports
100  // explicit conversion to bool.
101  struct OPERATORS_NOT_ALLOWED;
102  void true_value(OPERATORS_NOT_ALLOWED*) {}
103  };
104  typedef void (unspecified_bool::*unspecified_bool_type)(unspecified_bool::OPERATORS_NOT_ALLOWED*);
105 
106 #endif
107 
108 } // namespace detail
109 
110 } // namespace boost
111 
112 #define BOOST_EXPLICIT_OPERATOR_BOOL()\
113  BOOST_FORCEINLINE operator boost::detail::unspecified_bool_type () const\
114  {\
115  return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\
116  }
117 
118 #define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\
119  BOOST_FORCEINLINE operator boost::detail::unspecified_bool_type () const BOOST_NOEXCEPT\
120  {\
121  return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\
122  }
123 
124 #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\
125  BOOST_FORCEINLINE BOOST_CONSTEXPR operator boost::detail::unspecified_bool_type () const BOOST_NOEXCEPT\
126  {\
127  return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\
128  }
129 
130 #else // !defined(BOOST_NO_UNSPECIFIED_BOOL)
131 
132 #define BOOST_EXPLICIT_OPERATOR_BOOL()\
133  BOOST_FORCEINLINE operator bool () const\
134  {\
135  return !this->operator! ();\
136  }
137 
138 #define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\
139  BOOST_FORCEINLINE operator bool () const BOOST_NOEXCEPT\
140  {\
141  return !this->operator! ();\
142  }
143 
144 #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\
145  BOOST_FORCEINLINE BOOST_CONSTEXPR operator bool () const BOOST_NOEXCEPT\
146  {\
147  return !this->operator! ();\
148  }
149 
150 #endif // !defined(BOOST_NO_UNSPECIFIED_BOOL)
151 
152 #endif // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
153 
154 #endif // BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
const char * detail


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:14