aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/include/pybind11/operators.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/pybind11/include/pybind11/operators.h')
-rw-r--r--3rdparty/pybind11/include/pybind11/operators.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/3rdparty/pybind11/include/pybind11/operators.h b/3rdparty/pybind11/include/pybind11/operators.h
index b3dd62c3..086cb4cf 100644
--- a/3rdparty/pybind11/include/pybind11/operators.h
+++ b/3rdparty/pybind11/include/pybind11/operators.h
@@ -18,8 +18,8 @@
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
#endif
-NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
-NAMESPACE_BEGIN(detail)
+PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
+PYBIND11_NAMESPACE_BEGIN(detail)
/// Enumeration with all supported operator types
enum op_id : int {
@@ -147,6 +147,9 @@ PYBIND11_INPLACE_OPERATOR(ixor, operator^=, l ^= r)
PYBIND11_INPLACE_OPERATOR(ior, operator|=, l |= r)
PYBIND11_UNARY_OPERATOR(neg, operator-, -l)
PYBIND11_UNARY_OPERATOR(pos, operator+, +l)
+// WARNING: This usage of `abs` should only be done for existing STL overloads.
+// Adding overloads directly in to the `std::` namespace is advised against:
+// https://en.cppreference.com/w/cpp/language/extending_std
PYBIND11_UNARY_OPERATOR(abs, abs, std::abs(l))
PYBIND11_UNARY_OPERATOR(hash, hash, std::hash<L>()(l))
PYBIND11_UNARY_OPERATOR(invert, operator~, (~l))
@@ -157,11 +160,13 @@ PYBIND11_UNARY_OPERATOR(float, float_, (double) l)
#undef PYBIND11_BINARY_OPERATOR
#undef PYBIND11_INPLACE_OPERATOR
#undef PYBIND11_UNARY_OPERATOR
-NAMESPACE_END(detail)
+PYBIND11_NAMESPACE_END(detail)
using detail::self;
+// Add named operators so that they are accessible via `py::`.
+using detail::hash;
-NAMESPACE_END(PYBIND11_NAMESPACE)
+PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
#if defined(_MSC_VER)
# pragma warning(pop)