diff options
Diffstat (limited to 'options/slider.hpp')
-rw-r--r-- | options/slider.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/options/slider.hpp b/options/slider.hpp index da6bf214..5657ab82 100644 --- a/options/slider.hpp +++ b/options/slider.hpp @@ -20,6 +20,9 @@ namespace options class OTR_OPTIONS_EXPORT slider_value final { double cur_, min_, max_; + + template<typename t> + using arith_conversion_t = std::enable_if_t<std::is_arithmetic_v<std::decay_t<t>>, std::decay_t<t>>; public: slider_value(double cur, double min, double max); @@ -29,12 +32,18 @@ namespace options max_(double(max)) {} + template<typename t> + never_inline + explicit operator arith_conversion_t<t>() const + { + return t(cur_); + } + slider_value(const slider_value& v); slider_value(); slider_value& operator=(const slider_value& v); bool operator==(const slider_value& v) const; operator double() const { return cur_; } - explicit operator int() const { return iround(cur_); } double cur() const { return cur_; } double min() const { return min_; } double max() const { return max_; } |