From fcb0e975ab88a2faa86667b6a723ab2285035672 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 26 May 2024 21:04:36 +0200 Subject: a --- compat/non-const.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 compat/non-const.hpp (limited to 'compat') diff --git a/compat/non-const.hpp b/compat/non-const.hpp new file mode 100644 index 00000000..f04827b7 --- /dev/null +++ b/compat/non-const.hpp @@ -0,0 +1,15 @@ +#pragma once + +namespace floormat { + +template T& non_const(const T& value) { return const_cast(value); } +template T& non_const(T& value) = delete; +template T& non_const(T&&) = delete; +template T& non_const(const T&& value) = delete; + +template T& non_const_(const T& value) { return const_cast(value); } +template T& non_const_(T& value) { return value; } +template T& non_const_(T&& value) { return static_cast(value); } +template T& non_const_(const T&& value) { return static_cast(const_cast(value)); } + +} // namespace floormat -- cgit v1.2.3