summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-26 21:04:36 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-26 21:30:56 +0200
commitfcb0e975ab88a2faa86667b6a723ab2285035672 (patch)
tree9aeef968480b7be11cda5c93ea23e132c60084f6 /compat
parentafdb73b18329d1e135340ac4a7aab952648fada8 (diff)
a
Diffstat (limited to 'compat')
-rw-r--r--compat/non-const.hpp15
1 files changed, 15 insertions, 0 deletions
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<typename T> T& non_const(const T& value) { return const_cast<T&>(value); }
+template<typename T> T& non_const(T& value) = delete;
+template<typename T> T& non_const(T&&) = delete;
+template<typename T> T& non_const(const T&& value) = delete;
+
+template<typename T> T& non_const_(const T& value) { return const_cast<T&>(value); }
+template<typename T> T& non_const_(T& value) { return value; }
+template<typename T> T& non_const_(T&& value) { return static_cast<T&>(value); }
+template<typename T> T& non_const_(const T&& value) { return static_cast<T&>(const_cast<T&&>(value)); }
+
+} // namespace floormat