summaryrefslogtreecommitdiff
path: root/boost/contract/detail/operator_safe_bool.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
commitb8cf34c691623e4ec329053cbbf68522a855882d (patch)
tree34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/contract/detail/operator_safe_bool.hpp
parent3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff)
downloadboost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz
boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2
boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/contract/detail/operator_safe_bool.hpp')
-rw-r--r--boost/contract/detail/operator_safe_bool.hpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/boost/contract/detail/operator_safe_bool.hpp b/boost/contract/detail/operator_safe_bool.hpp
new file mode 100644
index 0000000000..65edc32dd8
--- /dev/null
+++ b/boost/contract/detail/operator_safe_bool.hpp
@@ -0,0 +1,73 @@
+
+#ifndef BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL_HPP_
+#define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL_HPP_
+
+// Copyright (C) 2008-2018 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0 (see accompanying
+// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
+// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
+
+#include <boost/contract/detail/name.hpp>
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+
+// NOTE: This code is inspired by <boost/shared_ptr/detail/operator_bool.hpp>.
+
+/* PRIVATE */
+
+// operator! is redundant, but some compilers need it.
+#define BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) \
+ bool operator!() const BOOST_NOEXCEPT { return !(bool_expr); }
+
+/* PUBLIC */
+
+#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) && \
+ !defined(BOOST_NO_CXX11_NULLPTR)
+ #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
+ explicit operator bool() const BOOST_NOEXCEPT { return (bool_expr); } \
+ BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
+#elif (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || \
+ defined(__CINT__)
+ #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
+ operator bool() const BOOST_NOEXCEPT { return (bool_expr); } \
+ BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
+#elif defined(_MANAGED)
+ #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
+ static void BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func)( \
+ this_type***) {} \
+ typedef void (*BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type))( \
+ this_type***); \
+ operator BOOST_CONTRACT_DETAIL_NANE(operator_safe_bool_type)() \
+ const BOOST_NOEXCEPT { \
+ return (bool_expr) ? \
+ &BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func) : 0; \
+ } \
+ BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
+#elif (defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200)) || \
+ (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304)) || \
+ (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590))
+ #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
+ void BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func)() const {} \
+ typedef void (this_type::*BOOST_CONTRACT_DETAIL_NAME1( \
+ operator_safe_bool_type))() const; \
+ operator BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type)() \
+ const BOOST_NOEXCEPT { \
+ return (bool_expr) ? &this_type:: \
+ BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func) : 0; \
+ } \
+ BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
+#else
+ #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \
+ void* BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_data); \
+ typedef void* this_type::*BOOST_CONTRACT_DETAIL_NAME1( \
+ operator_safe_bool_type);\
+ operator BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type)() \
+ const BOOST_NOEXCEPT { \
+ return (bool_expr) ? &this_type:: \
+ BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_data) : 0; \
+ } \
+ BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr)
+#endif
+
+#endif // #include guard
+