From aa427cb5fe7564a85703f14f76f854419274decc Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Wed, 4 Sep 2024 00:11:04 +0200 Subject: Bleh --- asl/utility.hpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'asl/utility.hpp') 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&&>(expr_)) +#define ASL_FWD(expr_) (static_cast(expr_)) + +namespace asl +{ + +template +T exchange(T& obj, U&& new_value) +{ + T old_value = ASL_MOVE(obj); + obj = ASL_FORWARD(new_value); + return old_value; +} + +} // namespace asl -- cgit