From d8d8ea71513cce0a2bd249abc3716afac2aafecf Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 29 Jun 2015 21:56:13 +0100 Subject: [PATCH] put EnableIf in template type params where possible --- octa/functional.hh | 14 ++++++-------- octa/map.hh | 21 ++++++++------------- octa/range.hh | 14 +++++++------- octa/set.hh | 21 ++++++++------------- octa/string.hh | 27 +++++++++++---------------- octa/vector.hh | 19 +++++++------------ 6 files changed, 47 insertions(+), 69 deletions(-) diff --git a/octa/functional.hh b/octa/functional.hh index 09a53ce..f0bfabc 100644 --- a/octa/functional.hh +++ b/octa/functional.hh @@ -700,10 +700,9 @@ struct Function: octa::detail::FunctionBase { f.p_stor.manager->call_copyf(p_stor, f.p_stor); } - template - Function(T f, EnableIf< - octa::detail::IsValidFunctor::value, bool - > = true) { + template::value + >> Function(T f) { if (func_is_null(f)) { init_empty(); return; @@ -747,10 +746,9 @@ struct Function: octa::detail::FunctionBase { initialize(f, AA(a)); } - template - Function(octa::AllocatorArg, const A &a, T f, EnableIf< - octa::detail::IsValidFunctor::value, bool - > = true) { + template::value + >> Function(octa::AllocatorArg, const A &a, T f) { if (func_is_null(f)) { init_empty(); return; diff --git a/octa/map.hh b/octa/map.hh index 156c015..7adc8ac 100644 --- a/octa/map.hh +++ b/octa/map.hh @@ -88,14 +88,11 @@ namespace detail { MapImpl(MapImpl &&m): Base(octa::move(m)) {} MapImpl(MapImpl &&m, const A &alloc): Base(octa::move(m), alloc) {} - template - MapImpl(R range, octa::Size size = 0, const H &hf = H(), - const C &eqf = C(), const A &alloc = A(), - octa::EnableIf< - octa::IsInputRange::value && - octa::IsConvertible, Value>::value, - bool - > = true + template::value && + octa::IsConvertible, Value>::value + >> MapImpl(R range, octa::Size size = 0, const H &hf = H(), + const C &eqf = C(), const A &alloc = A() ): Base(size ? size : octa::detail::estimate_hrsize(range), hf, eqf, alloc) { for (; !range.empty(); range.pop_front()) @@ -132,12 +129,10 @@ namespace detail { return *this; } - template - octa::EnableIf< + template::value && - octa::IsConvertible, Value>::value, - MapImpl & - > operator=(R range) { + octa::IsConvertible, Value>::value + >> MapImpl &operator=(R range) { Base::assign_range(range); return *this; } diff --git a/octa/range.hh b/octa/range.hh index a09ff03..ee7a5a6 100644 --- a/octa/range.hh +++ b/octa/range.hh @@ -250,9 +250,9 @@ public: RangeHalf(const T &range): p_range(range) {} - template RangeHalf(const RangeHalf &half, - octa::EnableIf::value, bool> = true - ): p_range(half.p_range) {} + template::value + >> RangeHalf(const RangeHalf &half): p_range(half.p_range) {} RangeHalf(RangeHalf &&half): p_range(octa::move(half.p_range)) {} @@ -749,10 +749,10 @@ struct PointerRange: InputRange, FiniteRandomAccessRangeTag, T> PointerRange(T *beg, T *end): p_beg(beg), p_end(end) {} PointerRange(T *beg, octa::Size n): p_beg(beg), p_end(beg + n) {} - template - PointerRange(const PointerRange &v, octa::EnableIf< - octa::IsConvertible::value, bool - > = true): p_beg(&v[0]), p_end(&v[v.size()]) {} + template::value + >> PointerRange(const PointerRange &v): + p_beg(&v[0]), p_end(&v[v.size()]) {} PointerRange &operator=(const PointerRange &v) { p_beg = v.p_beg; diff --git a/octa/set.hh b/octa/set.hh index 0af3434..e8d4ebe 100644 --- a/octa/set.hh +++ b/octa/set.hh @@ -74,14 +74,11 @@ namespace detail { SetImpl(SetImpl &&m): Base(octa::move(m)) {} SetImpl(SetImpl &&m, const A &alloc): Base(octa::move(m), alloc) {} - template - SetImpl(R range, octa::Size size = 0, const H &hf = H(), - const C &eqf = C(), const A &alloc = A(), - octa::EnableIf< - octa::IsInputRange::value && - octa::IsConvertible, Value>::value, - bool - > = true + template::value && + octa::IsConvertible, Value>::value + >> SetImpl(R range, octa::Size size = 0, const H &hf = H(), + const C &eqf = C(), const A &alloc = A() ): Base(size ? size : octa::detail::estimate_hrsize(range), hf, eqf, alloc) { for (; !range.empty(); range.pop_front()) @@ -118,12 +115,10 @@ namespace detail { return *this; } - template - octa::EnableIf< + template::value && - octa::IsConvertible, Value>::value, - SetImpl & - > operator=(R range) { + octa::IsConvertible, Value>::value + >> SetImpl &operator=(R range) { Base::assign_range(range); return *this; } diff --git a/octa/string.hh b/octa/string.hh index a1065c2..682b258 100644 --- a/octa/string.hh +++ b/octa/string.hh @@ -30,10 +30,10 @@ struct StringRangeBase: InputRange< StringRangeBase(const StringBase &s): p_beg(s.data()), p_end(s.data() + s.size()) {} - template - StringRangeBase(const StringRangeBase &v, octa::EnableIf< - octa::IsConvertible::value, bool - > = true): p_beg(&v[0]), p_end(&v[v.size()]) {} + template::value + >> StringRangeBase(const StringRangeBase &v): + p_beg(&v[0]), p_end(&v[v.size()]) {} StringRangeBase &operator=(const StringRangeBase &v) { p_beg = v.p_beg; p_end = v.p_end; return *this; @@ -177,13 +177,10 @@ public: StringBase(const Value *v, Size n, const A &a = A()): p_buf(ConstRange(v, n), a) {} - template StringBase(R range, const A &a = A(), - octa::EnableIf< - octa::IsInputRange::value && - octa::IsConvertible, Value>::value, - bool - > = true - ): p_buf(range, a) { + template::value && + octa::IsConvertible, Value>::value + >> StringBase(R range, const A &a = A()): p_buf(range, a) { terminate(); } @@ -201,12 +198,10 @@ public: p_buf = ConstRange(v, strlen(v) + 1); return *this; } - template - octa::EnableIf< + template::value && - octa::IsConvertible, Value>::value, - StringBase & - > operator=(const R &r) { + octa::IsConvertible, Value>::value + >> StringBase &operator=(const R &r) { p_buf = r; terminate(); return *this; diff --git a/octa/vector.hh b/octa/vector.hh index f5da0c2..56145c3 100644 --- a/octa/vector.hh +++ b/octa/vector.hh @@ -161,13 +161,10 @@ public: Vector(InitializerList v, const A &a = A()): Vector(v.begin(), v.size(), a) {} - template Vector(R range, const A &a = A(), - octa::EnableIf< - octa::IsInputRange::value && - octa::IsConvertible, Value>::value, - bool - > = true - ): Vector(a) { + template::value && + octa::IsConvertible, Value>::value + >> Vector(R range, const A &a = A()): Vector(a) { ctor_from_range(range); } @@ -231,12 +228,10 @@ public: return *this; } - template - octa::EnableIf< + template::value && - octa::IsConvertible, Value>::value, - Vector & - > operator=(R range) { + octa::IsConvertible, Value>::value + >> Vector &operator=(R range) { clear(); ctor_from_range(range); return *this;