diff options
author | crupest <crupest@outlook.com> | 2018-11-25 22:57:07 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-11-25 22:57:07 +0800 |
commit | 22322daf6f51da53740ff95ef2eaceed9a6efcae (patch) | |
tree | 06b17b482e2e15cb0692d05b279c61cbd6923b4d /src/base.hpp | |
parent | 5391e781e4682731721c841462904809bc618870 (diff) | |
download | cru-22322daf6f51da53740ff95ef2eaceed9a6efcae.tar.gz cru-22322daf6f51da53740ff95ef2eaceed9a6efcae.tar.bz2 cru-22322daf6f51da53740ff95ef2eaceed9a6efcae.zip |
Develop basic functions of ScrollControl.
Diffstat (limited to 'src/base.hpp')
-rw-r--r-- | src/base.hpp | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/base.hpp b/src/base.hpp index 5d8cb9ce..fdd736a0 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -8,9 +8,6 @@ #include <stdexcept> #include <string_view> #include <chrono> -#include <optional> -// ReSharper disable once CppUnusedIncludeDirective -#include <type_traits> namespace cru { @@ -60,31 +57,4 @@ namespace cru if (!condition) throw std::invalid_argument(error_message.data()); } - - template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> - float Coerce(const T n, const std::optional<T> min, const std::optional<T> max) - { - if (min.has_value() && n < min.value()) - return min.value(); - if (max.has_value() && n > max.value()) - return max.value(); - return n; - } - - template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> - float Coerce(const T n, const std::nullopt_t, const std::optional<T> max) - { - if (max.has_value() && n > max.value()) - return max.value(); - return n; - } - - template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> - float Coerce(const T n, const std::optional<T> min, const std::nullopt_t) - { - if (min.has_value() && n < min.value()) - return min.value(); - return n; - } - } |