diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 05:27:56 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 05:27:56 +0200 |
commit | 069b5fbdd326b5b8965a789880633e02cf9a54a2 (patch) | |
tree | f7e1dfda64a3e72523193a05c3f43072ba79b550 /options | |
parent | de29cf1031b5898541c0888b5ee6f0bdbbed43d7 (diff) |
options/slider: allow arbitrary cast
Diffstat (limited to 'options')
-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_; } |