From 6571b78ffd9f74f9e863ff4c78b8ddebb53d52c5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 5 Aug 2016 17:04:34 +0200 Subject: compat/options: simplify getter No need to write the static_cast long form at caller site. --- opentrack-compat/options.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/opentrack-compat/options.hpp b/opentrack-compat/options.hpp index 53249746..fd4a82a5 100644 --- a/opentrack-compat/options.hpp +++ b/opentrack-compat/options.hpp @@ -234,7 +234,7 @@ namespace options { public: using underlying_t = typename get_t::t; - t operator=(const t datum) + t operator=(const t& datum) { store(static_cast(datum)); return datum; @@ -256,7 +256,7 @@ namespace options { { } - operator t() const + t get() const { t val = b->contains(self_name) ? static_cast(b->get(self_name)) @@ -264,10 +264,13 @@ namespace options { return detail::value_get_traits::get(val, def); } + operator t() const { return get(); } + void reload() override { *this = static_cast(*this); } + private: t def; }; -- cgit v1.2.3