summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/functional.hpp11
-rw-r--r--compat/simple-mat.hpp42
2 files changed, 25 insertions, 28 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 <type_traits>
#include <vector>
-template<typename t>
-using remove_qualifiers = std::remove_cv_t<std::remove_reference_t<t>>;
-
namespace functools
{
@@ -53,8 +50,8 @@ struct constant final
template<typename seq_, typename F>
auto map(F&& fun, const seq_& seq)
{
- using value_type = remove_qualifiers<typename std::iterator_traits<decltype(std::begin(seq))>::value_type>;
- using ret_type = remove_qualifiers<decltype(fun(std::declval<value_type>()))>;
+ using value_type = std::decay_t<typename std::iterator_traits<decltype(std::begin(seq))>::value_type>;
+ using ret_type = std::decay_t<decltype(fun(std::declval<value_type>()))>;
std::vector<ret_type> 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<seq_>;
- using value_type = remove_qualifiers<typename std::iterator_traits<decltype(std::begin(seq))>::value_type>;
+ using seq_type = std::decay_t<seq_>;
+ using value_type = std::decay_t<typename std::iterator_traits<decltype(std::begin(seq))>::value_type>;
using fun_ret_type = decltype(fun(std::declval<value_type>()));
static_assert(std::is_convertible<fun_ret_type, bool>::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<int Q = w_> typename std::enable_if<equals<Q, 1, 0>::value, num>::type
+ template<int Q = w_> std::enable_if_t<equals<Q, 1, 0>::value, num>
inline operator()(int i) const { return data[i][0]; }
- template<int P = h_> typename std::enable_if<equals<P, 1, 1>::value, num>::type
+ template<int P = h_> std::enable_if_t<equals<P, 1, 1>::value, num>
inline operator()(int i) const { return data[0][i]; }
- template<int Q = w_> typename std::enable_if<equals<Q, 1, 2>::value, num&>::type
+ template<int Q = w_> std::enable_if_t<equals<Q, 1, 2>::value, num&>
inline operator()(int i) { return data[i][0]; }
- template<int P = h_> typename std::enable_if<equals<P, 1, 3>::value, num&>::type
+ template<int P = h_> std::enable_if_t<equals<P, 1, 3>::value, num&>
inline operator()(int i) { return data[0][i]; }
- template<int Q = w_> typename std::enable_if<equals<Q, 1, 0>::value, num>::type
+ template<int Q = w_> std::enable_if_t<equals<Q, 1, 0>::value, num>
inline operator()(unsigned i) const { return data[i][0]; }
- template<int P = h_> typename std::enable_if<equals<P, 1, 1>::value, num>::type
+ template<int P = h_> std::enable_if_t<equals<P, 1, 1>::value, num>
inline operator()(unsigned i) const { return data[0][i]; }
- template<int Q = w_> typename std::enable_if<equals<Q, 1, 2>::value, num&>::type
+ template<int Q = w_> std::enable_if_t<equals<Q, 1, 2>::value, num&>
inline operator()(unsigned i) { return data[i][0]; }
- template<int P = h_> typename std::enable_if<equals<P, 1, 3>::value, num&>::type
+ template<int P = h_> std::enable_if_t<equals<P, 1, 3>::value, num&>
inline operator()(unsigned i) { return data[0][i]; }
#define OPENTRACK_ASSERT_SWIZZLE static_assert(P == h_ && Q == w_, "")
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 1>::value, num>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 1>::value, num>
x() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(0); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 2>::value, num>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 2>::value, num>
y() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(1); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 3>::value, num>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 3>::value, num>
z() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(2); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 4>::value, num>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 4>::value, num>
w() const { OPENTRACK_ASSERT_SWIZZLE; return operator()(3); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 1>::value, num&>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 1>::value, num&>
x() { OPENTRACK_ASSERT_SWIZZLE; return operator()(0); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 2>::value, num&>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 2>::value, num&>
y() { OPENTRACK_ASSERT_SWIZZLE; return operator()(1); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 3>::value, num&>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 3>::value, num&>
z() { OPENTRACK_ASSERT_SWIZZLE; return operator()(2); }
- template<int P = h_, int Q = w_> typename std::enable_if<maybe_add_swizzle<P, Q, 4>::value, num&>::type
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 4>::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<int R, int S, int P = h_, int Q = w_>
- typename std::enable_if<is_vector_pair<R, S, P, Q>::value, num>::type
+ std::enable_if_t<is_vector_pair<R, S, P, Q>::value, num>
norm() const
{
static_assert(P == h_ && Q == w_, "");
@@ -126,7 +126,7 @@ public:
}
template<int R, int S, int P = h_, int Q = w_>
- typename std::enable_if<is_vector_pair<R, S, P, Q>::value, num>::type
+ std::enable_if_t<is_vector_pair<R, S, P, Q>::value, num>
dot(const Mat<num, R, S>& p2) const
{
static_assert(P == h_ && Q == w_, "");
@@ -139,7 +139,7 @@ public:
}
template<int R, int S, int P = h_, int Q = w_>
- typename std::enable_if<is_dim3<P, Q, R, S>::value, Mat<num, is_dim3<P, Q, R, S>::P, is_dim3<P, Q, R, S>::Q>>::type
+ std::enable_if_t<is_dim3<P, Q, R, S>::value, Mat<num, is_dim3<P, Q, R, S>::P, is_dim3<P, Q, R, S>::Q>>
cross(const Mat<num, R, S>& b) const
{
static_assert(P == h_ && Q == w_, "");
@@ -212,7 +212,7 @@ public:
#endif
template<typename... ts, int h__ = h_, int w__ = w_,
- typename = typename std::enable_if<is_arglist_correct<num, h__, w__, ts...>::value>::type>
+ typename = std::enable_if_t<is_arglist_correct<num, h__, w__, ts...>::value>>
Mat(const ts... xs) : data{static_cast<num>(xs)...}
{
static_assert(h__ == h_ && w__ == w_, "");
@@ -243,7 +243,7 @@ public:
// not needed merely for matrix algebra -sh 20141030
template<int h__ = h_>
- static typename std::enable_if<h_ == w_, Mat<num, h__, h__>>::type eye()
+ static std::enable_if_t<h_ == w_, Mat<num, h__, h__>> eye()
{
static_assert(h_ == h__, "");