From 742fdf7d20936cd71a009f96dfb94610b336bc97 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 10 Aug 2017 16:14:30 +0200 Subject: use c++14 features --- compat/functional.hpp | 11 ++++------- compat/simple-mat.hpp | 42 +++++++++++++++++++++--------------------- options/tie.hpp | 2 +- options/value-traits.hpp | 2 +- 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/compat/functional.hpp b/compat/functional.hpp index fcf6393c..f7cd95c7 100644 --- a/compat/functional.hpp +++ b/compat/functional.hpp @@ -5,9 +5,6 @@ #include #include -template -using remove_qualifiers = std::remove_cv_t>; - namespace functools { @@ -53,8 +50,8 @@ struct constant final template auto map(F&& fun, const seq_& seq) { - using value_type = remove_qualifiers::value_type>; - using ret_type = remove_qualifiers()))>; + using value_type = std::decay_t::value_type>; + using ret_type = std::decay_t()))>; std::vector ret; auto it = std::back_inserter(ret); @@ -70,8 +67,8 @@ auto remove_if_not(F&& fun, const seq_& seq) { using namespace functools; - using seq_type = remove_qualifiers; - using value_type = remove_qualifiers::value_type>; + using seq_type = std::decay_t; + using value_type = std::decay_t::value_type>; using fun_ret_type = decltype(fun(std::declval())); static_assert(std::is_convertible::value, "must return bool"); diff --git a/compat/simple-mat.hpp b/compat/simple-mat.hpp index ca49ea5a..d983f79b 100644 --- a/compat/simple-mat.hpp +++ b/compat/simple-mat.hpp @@ -58,61 +58,61 @@ class Mat num data[h_][w_]; public: - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> inline operator()(int i) const { return data[i][0]; } - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> inline operator()(int i) const { return data[0][i]; } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> inline operator()(int i) { return data[i][0]; } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> inline operator()(int i) { return data[0][i]; } - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> inline operator()(unsigned i) const { return data[i][0]; } - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> inline operator()(unsigned i) const { return data[0][i]; } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> inline operator()(unsigned i) { return data[i][0]; } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> inline operator()(unsigned i) { return data[0][i]; } #define OPENTRACK_ASSERT_SWIZZLE static_assert(P == h_ && Q == w_, "") - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> x() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(0); } - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> y() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(1); } - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> z() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(2); } - template typename std::enable_if::value, num>::type + template std::enable_if_t::value, num> w() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(3); } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> x() { OPENTRACK_ASSERT_SWIZZLE; return operator()(0); } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> y() { OPENTRACK_ASSERT_SWIZZLE; return operator()(1); } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> z() { OPENTRACK_ASSERT_SWIZZLE; return operator()(2); } - template typename std::enable_if::value, num&>::type + template std::enable_if_t::value, num&> w() { OPENTRACK_ASSERT_SWIZZLE; return operator()(3); } // parameters w_ and h_ are rebound so that SFINAE occurs // removing them causes a compile-time error -sh 20150811 template - typename std::enable_if::value, num>::type + std::enable_if_t::value, num> norm() const { static_assert(P == h_ && Q == w_, ""); @@ -126,7 +126,7 @@ public: } template - typename std::enable_if::value, num>::type + std::enable_if_t::value, num> dot(const Mat& p2) const { static_assert(P == h_ && Q == w_, ""); @@ -139,7 +139,7 @@ public: } template - typename std::enable_if::value, Mat::P, is_dim3::Q>>::type + std::enable_if_t::value, Mat::P, is_dim3::Q>> cross(const Mat& b) const { static_assert(P == h_ && Q == w_, ""); @@ -212,7 +212,7 @@ public: #endif template::value>::type> + typename = std::enable_if_t::value>> Mat(const ts... xs) : data{static_cast(xs)...} { static_assert(h__ == h_ && w__ == w_, ""); @@ -243,7 +243,7 @@ public: // not needed merely for matrix algebra -sh 20141030 template - static typename std::enable_if>::type eye() + static std::enable_if_t> eye() { static_assert(h_ == h__, ""); diff --git a/options/tie.hpp b/options/tie.hpp index e8c1006f..92e98680 100644 --- a/options/tie.hpp +++ b/options/tie.hpp @@ -30,7 +30,7 @@ namespace options { template -typename std::enable_if::value>::type +std::enable_if_t::value> tie_setting(value& v, QComboBox* cb) { cb->setCurrentIndex(cb->findData(int(static_cast(v)))); diff --git a/options/value-traits.hpp b/options/value-traits.hpp index cf12649c..8a497aca 100644 --- a/options/value-traits.hpp +++ b/options/value-traits.hpp @@ -13,7 +13,7 @@ namespace detail { template struct default_value_traits { - using element_type = remove_qualifiers; + using element_type = std::decay_t; using value_type = u; static inline value_type from_value(const value_type& val, const value_type&) { return val; } -- cgit v1.2.3