summaryrefslogtreecommitdiff
path: root/absl/base/optimization.h
diff options
context:
space:
mode:
authorGravatar Evan Brown <ezb@google.com>2022-09-20 13:12:25 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-20 13:13:13 -0700
commitd859fafe1ab9edc9c04ca262d9993be82c757881 (patch)
tree6794fb010d0f423ea6a8fb65176efb9231ad095d /absl/base/optimization.h
parent800c04f64afa48271c6eaee67da489a7ebf92757 (diff)
Change the macro ABSL_IS_TRIVIALLY_RELOCATABLE into a type trait - absl::is_trivially_relocatable - and move it from optimization.h to type_traits.h.
Example of how to change to the new type trait: ``` #include "absl/base/attributes.h" if (ABSL_IS_TRIVIALLY_RELOCATABLE(T)) { DoSomething(); } ``` to ``` #include "absl/meta/type_traits.h" if (absl::is_trivially_relocatable<T>::value) { DoSomething(); } ``` Note that optimization.h is also built in C mode so we can't put a type trait there. PiperOrigin-RevId: 475633715 Change-Id: I2bc85f3f6711d1280049fd01eb97c497d2d0d929
Diffstat (limited to 'absl/base/optimization.h')
-rw-r--r--absl/base/optimization.h24
1 files changed, 0 insertions, 24 deletions
diff --git a/absl/base/optimization.h b/absl/base/optimization.h
index 57999a18..db5cc097 100644
--- a/absl/base/optimization.h
+++ b/absl/base/optimization.h
@@ -249,28 +249,4 @@
#define ABSL_INTERNAL_UNIQUE_SMALL_NAME()
#endif
-// ABSL_IS_TRIVIALLY_RELOCATABLE(type)
-// Detects whether a type is "trivially relocatable" -- meaning it can be
-// relocated without invoking the constructor/destructor, using a form of move
-// elision.
-//
-// Example:
-//
-// if constexpr (ABSL_IS_TRIVIALLY_RELOCATABLE(T)) {
-// memcpy(new_location, old_location, sizeof(T));
-// } else {
-// new(new_location) T(std::move(*old_location));
-// old_location->~T();
-// }
-//
-// Upstream documentation:
-//
-// https://clang.llvm.org/docs/LanguageExtensions.html#:~:text=__is_trivially_relocatable
-//
-#if ABSL_HAVE_BUILTIN(__is_trivially_relocatable)
-#define ABSL_IS_TRIVIALLY_RELOCATABLE(type) __is_trivially_relocatable(type)
-#else
-#define ABSL_IS_TRIVIALLY_RELOCATABLE(type) false
-#endif
-
#endif // ABSL_BASE_OPTIMIZATION_H_