diff options
Diffstat (limited to 'compat/non-const.hpp')
| -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 |
