summaryrefslogtreecommitdiff
path: root/asl/utility.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-09-04 00:11:04 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-09-04 00:11:04 +0200
commitaa427cb5fe7564a85703f14f76f854419274decc (patch)
tree8395e90d6ce25f8044fb5d2a1a21eecb6e80ed08 /asl/utility.hpp
parentf0a94256e25c844ca2ff99377bc8b2fb94f69e84 (diff)
Bleh
Diffstat (limited to 'asl/utility.hpp')
-rw-r--r--asl/utility.hpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/asl/utility.hpp b/asl/utility.hpp
index a94834d..6cbff8e 100644
--- a/asl/utility.hpp
+++ b/asl/utility.hpp
@@ -1,12 +1,20 @@
#pragma once
-#ifndef __clang__
- #error Not a valid environment
-#endif
+#include "asl/meta.hpp"
-#ifdef _MSC_VER
- #define ASL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
-#else
- #define ASL_NO_UNIQUE_ADDRESS [[no_unique_address]]
-#endif
+#define ASL_MOVE(expr_) (static_cast<::asl::un_ref_t<decltype(expr_)>&&>(expr_))
+#define ASL_FWD(expr_) (static_cast<decltype(expr_)&&>(expr_))
+
+namespace asl
+{
+
+template<typename T, typename U>
+T exchange(T& obj, U&& new_value)
+{
+ T old_value = ASL_MOVE(obj);
+ obj = ASL_FORWARD(new_value);
+ return old_value;
+}
+
+} // namespace asl