diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 21:04:36 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 21:30:56 +0200 |
commit | fcb0e975ab88a2faa86667b6a723ab2285035672 (patch) | |
tree | 9aeef968480b7be11cda5c93ea23e132c60084f6 /compat | |
parent | afdb73b18329d1e135340ac4a7aab952648fada8 (diff) |
a
Diffstat (limited to 'compat')
-rw-r--r-- | compat/non-const.hpp | 15 |
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 |