diff options
author | Benjamin Barenblat <bbaren@google.com> | 2022-07-12 21:47:19 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2022-07-12 21:47:19 -0400 |
commit | d055841ab4147dac20d5c46d04ca3a2fb13748b7 (patch) | |
tree | 15a01389c86f10a8844ff2a86bddf46640d065e8 /absl/base/internal/exception_safety_testing.h | |
parent | 2d23a3e16abfcf8f22ba850d67e972cc77e98874 (diff) | |
parent | 273292d1cfc0a94a65082ee350509af1d113344d (diff) | |
download | abseil-d055841ab4147dac20d5c46d04ca3a2fb13748b7.tar.gz abseil-d055841ab4147dac20d5c46d04ca3a2fb13748b7.tar.bz2 abseil-d055841ab4147dac20d5c46d04ca3a2fb13748b7.zip |
Merge new upstream LTS 20220623.0
Diffstat (limited to 'absl/base/internal/exception_safety_testing.h')
-rw-r--r-- | absl/base/internal/exception_safety_testing.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/absl/base/internal/exception_safety_testing.h b/absl/base/internal/exception_safety_testing.h index 6ba89d05..77a5aec6 100644 --- a/absl/base/internal/exception_safety_testing.h +++ b/absl/base/internal/exception_safety_testing.h @@ -536,7 +536,22 @@ class ThrowingValue : private exceptions_internal::TrackedObject { } // Memory management operators - // Args.. allows us to overload regular and placement new in one shot + static void* operator new(size_t s) noexcept( + IsSpecified(TypeSpec::kNoThrowNew)) { + if (!IsSpecified(TypeSpec::kNoThrowNew)) { + exceptions_internal::MaybeThrow(ABSL_PRETTY_FUNCTION, true); + } + return ::operator new(s); + } + + static void* operator new[](size_t s) noexcept( + IsSpecified(TypeSpec::kNoThrowNew)) { + if (!IsSpecified(TypeSpec::kNoThrowNew)) { + exceptions_internal::MaybeThrow(ABSL_PRETTY_FUNCTION, true); + } + return ::operator new[](s); + } + template <typename... Args> static void* operator new(size_t s, Args&&... args) noexcept( IsSpecified(TypeSpec::kNoThrowNew)) { @@ -557,12 +572,6 @@ class ThrowingValue : private exceptions_internal::TrackedObject { // Abseil doesn't support throwing overloaded operator delete. These are // provided so a throwing operator-new can clean up after itself. - // - // We provide both regular and templated operator delete because if only the - // templated version is provided as we did with operator new, the compiler has - // no way of knowing which overload of operator delete to call. See - // https://en.cppreference.com/w/cpp/memory/new/operator_delete and - // https://en.cppreference.com/w/cpp/language/delete for the gory details. void operator delete(void* p) noexcept { ::operator delete(p); } template <typename... Args> @@ -726,9 +735,8 @@ class ThrowingAllocator : private exceptions_internal::TrackedObject { ThrowingAllocator select_on_container_copy_construction() noexcept( IsSpecified(AllocSpec::kNoThrowAllocate)) { - auto& out = *this; ReadStateAndMaybeThrow(ABSL_PRETTY_FUNCTION); - return out; + return *this; } template <typename U> |