summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/templates/safe_refcount.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/godot_cpp/templates/safe_refcount.hpp')
-rw-r--r--include/godot_cpp/templates/safe_refcount.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/godot_cpp/templates/safe_refcount.hpp b/include/godot_cpp/templates/safe_refcount.hpp
index f865041..519bbf7 100644
--- a/include/godot_cpp/templates/safe_refcount.hpp
+++ b/include/godot_cpp/templates/safe_refcount.hpp
@@ -48,6 +48,15 @@ namespace godot {
// value and, as an important benefit, you can be sure the value is properly synchronized
// even with threads that are already running.
+// These are used in very specific areas of the engine where it's critical that these guarantees are held
+#define SAFE_NUMERIC_TYPE_PUN_GUARANTEES(m_type) \
+ static_assert(sizeof(SafeNumeric<m_type>) == sizeof(m_type)); \
+ static_assert(alignof(SafeNumeric<m_type>) == alignof(m_type)); \
+ static_assert(std::is_trivially_destructible<std::atomic<m_type>>::value);
+#define SAFE_FLAG_TYPE_PUN_GUARANTEES \
+ static_assert(sizeof(SafeFlag) == sizeof(bool)); \
+ static_assert(alignof(SafeFlag) == alignof(bool));
+
template <class T>
class SafeNumeric {
std::atomic<T> value;