From 069b5fbdd326b5b8965a789880633e02cf9a54a2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 20 Oct 2017 05:27:56 +0200 Subject: options/slider: allow arbitrary cast --- options/slider.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'options') 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 + using arith_conversion_t = std::enable_if_t>, std::decay_t>; public: slider_value(double cur, double min, double max); @@ -29,12 +32,18 @@ namespace options max_(double(max)) {} + template + never_inline + explicit operator arith_conversion_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_; } -- cgit v1.2.3