summaryrefslogtreecommitdiff
path: root/src/mongo/stdx
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2021-10-18 14:46:32 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-22 10:22:18 +0000
commitbc2ae9aa30c2b3fff3471687678752bb01000113 (patch)
tree967193881d6a168e6efb39683cbfaa0236e371ec /src/mongo/stdx
parent73d9915e678306c357c9bdfa3e3fd949face360f (diff)
downloadmongo-bc2ae9aa30c2b3fff3471687678752bb01000113.tar.gz
SERVER-60787 Force alignment with std::aligned_storage not inheritance
Diffstat (limited to 'src/mongo/stdx')
-rw-r--r--src/mongo/stdx/new.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mongo/stdx/new.h b/src/mongo/stdx/new.h
index 1219454df11..11dfd48179f 100644
--- a/src/mongo/stdx/new.h
+++ b/src/mongo/stdx/new.h
@@ -29,11 +29,13 @@
#pragma once
-#include "mongo/config.h"
-
#include <cstddef>
+#include <cstdint>
#include <new>
+#include "mongo/config.h"
+#include "mongo/platform/compiler.h"
+
namespace mongo {
namespace stdx {
@@ -42,7 +44,8 @@ namespace stdx {
!(defined(__cpp_lib_hardware_interference_size) && !defined(_LIBCPP_VERSION))
#if defined(MONGO_CONFIG_MAX_EXTENDED_ALIGNMENT)
-static_assert(MONGO_CONFIG_MAX_EXTENDED_ALIGNMENT >= sizeof(uint64_t), "Bad extended alignment");
+static_assert(MONGO_CONFIG_MAX_EXTENDED_ALIGNMENT >= sizeof(std::uint64_t),
+ "Bad extended alignment");
constexpr std::size_t hardware_destructive_interference_size = MONGO_CONFIG_MAX_EXTENDED_ALIGNMENT;
#else
constexpr std::size_t hardware_destructive_interference_size = alignof(std::max_align_t);
@@ -55,7 +58,16 @@ constexpr auto hardware_constructive_interference_size = hardware_destructive_in
using std::hardware_constructive_interference_size;
using std::hardware_destructive_interference_size;
-#endif
+#endif // hardware_interference_size
+
+#if __cpp_lib_launder >= 201606
+using std::launder;
+#else
+template <typename T>
+MONGO_WARN_UNUSED_RESULT_FUNCTION constexpr T* launder(T* p) noexcept {
+ return p;
+}
+#endif // launder
} // namespace stdx
} // namespace mongo