diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-24 18:54:34 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-24 19:32:10 +0100 |
commit | a88e34b21b07f70123926fcb5c505d6afdf99807 (patch) | |
tree | 905059194dcc64c7c163b8912947d8173fd4cc91 /options/value-traits.hpp | |
parent | 5bf85412e4eacf92acc936b6e74bce0e2b1055d9 (diff) |
style/quality only
No functional changes.
- add `override' everywhere where missing
- almost pass clang's `-Wweak-vtables'
- avoid some float/double conversions
- remove unused private members
- make signedness conversions explicit
- put stuff in right namespaces to aid analysis
Diffstat (limited to 'options/value-traits.hpp')
-rw-r--r-- | options/value-traits.hpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/options/value-traits.hpp b/options/value-traits.hpp index f5b74f73..765740f6 100644 --- a/options/value-traits.hpp +++ b/options/value-traits.hpp @@ -79,26 +79,13 @@ struct value_traits : default_value_traits<t> {}; template<> struct value_traits<double> : default_value_traits<double> { - static bool is_equal(value_type x, value_type y) - { - if (x == y) - return true; - else - { - using I = std::int64_t; - constexpr int K = 1000; - - value_type x_, y_; - - return I(std::modf(x, &x_) * K) == I(std::modf(y, &y_) * K) && - I(x_) == I(y_); - } - } + static bool is_equal(value_type x, value_type y) { return std::fabs(x - y) < 1e-6; } }; -template<> struct value_traits<float> : value_traits<float, double> +template<> +struct value_traits<float> : default_value_traits<float> { - static constexpr inline value_type pass_value(const value_type& x) { return x; } + static bool is_equal(value_type x, value_type y) { return std::fabs(x - y) < 1e-6f; } }; template<> |