From bc0c3f7577846844c6f2530ff62e57f2d4ac1885 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 16 Jan 2016 18:45:55 +0000 Subject: [PATCH] convert some stuff to variable templates --- ostd/internal/tuple.hh | 72 +++++++++++++++++++----------------------- ostd/tuple.hh | 27 ++++++++-------- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/ostd/internal/tuple.hh b/ostd/internal/tuple.hh index 89de645..a12789d 100644 --- a/ostd/internal/tuple.hh +++ b/ostd/internal/tuple.hh @@ -181,99 +181,93 @@ namespace detail { namespace detail { template - struct TupleConvertibleBase: False {}; + constexpr bool TupleConvertibleBase = false; template - struct TupleConvertibleBase, TupleTypes>: - Constant && - TupleConvertibleBase, - TupleTypes>::value> {}; + constexpr bool TupleConvertibleBase, TupleTypes> + = IsConvertible && TupleConvertibleBase, + TupleTypes>; template<> - struct TupleConvertibleBase, TupleTypes<>>: True {}; + constexpr bool TupleConvertibleBase, TupleTypes<>> = true; template - struct TupleConvertibleApply: False {}; + constexpr bool TupleConvertibleApply = false; template - struct TupleConvertibleApply: TupleConvertibleBase< - MakeTupleTypes, MakeTupleTypes - > {}; + constexpr bool TupleConvertibleApply + = TupleConvertibleBase, MakeTupleTypes>; template>::value, bool = IsTupleLike::value> - struct TupleConvertible: False {}; + constexpr bool TupleConvertible = false; template - struct TupleConvertible: TupleConvertibleApply< + constexpr bool TupleConvertible = TupleConvertibleApply< TupleSize>::value == TupleSize::value, T, U - > {}; + >; } /* tuple constructible */ namespace detail { template - struct TupleConstructibleBase: False {}; + constexpr bool TupleConstructibleBase = false; template - struct TupleConstructibleBase, TupleTypes>: - Constant && - TupleConstructibleBase, - TupleTypes>::value> {}; + constexpr bool TupleConstructibleBase, TupleTypes> + = IsConstructible && TupleConstructibleBase, + TupleTypes>; template<> - struct TupleConstructibleBase, TupleTypes<>>: True {}; + constexpr bool TupleConstructibleBase, TupleTypes<>> = true; template - struct TupleConstructibleApply: False {}; + constexpr bool TupleConstructibleApply = false; template - struct TupleConstructibleApply: TupleConstructibleBase< - MakeTupleTypes, MakeTupleTypes - > {}; + constexpr bool TupleConstructibleApply + = TupleConstructibleBase, MakeTupleTypes>; template>::value, bool = IsTupleLike::value> - struct TupleConstructible: False {}; + constexpr bool TupleConstructible = false; template - struct TupleConstructible: TupleConstructibleApply< + constexpr bool TupleConstructible = TupleConstructibleApply< TupleSize>::value == TupleSize::value, T, U - > {}; + >; } /* tuple assignable */ namespace detail { template - struct TupleAssignableBase: False {}; + constexpr bool TupleAssignableBase = false; template - struct TupleAssignableBase, TupleTypes>: - Constant && - TupleAssignableBase, - TupleTypes>::value> {}; + constexpr bool TupleAssignableBase, TupleTypes> + = IsAssignable && TupleAssignableBase, + TupleTypes>; template<> - struct TupleAssignableBase, TupleTypes<>>: True {}; + constexpr bool TupleAssignableBase, TupleTypes<>> = true; template - struct TupleAssignableApply: False {}; + constexpr bool TupleAssignableApply = false; template - struct TupleAssignableApply: TupleAssignableBase< - MakeTupleTypes, MakeTupleTypes - > {}; + constexpr bool TupleAssignableApply + = TupleAssignableBase, MakeTupleTypes>; template>::value, bool = IsTupleLike::value> - struct TupleAssignable: False {}; + constexpr bool TupleAssignable = false; template - struct TupleAssignable: TupleAssignableApply< + constexpr bool TupleAssignable = TupleAssignableApply< TupleSize>::value == TupleSize::value, T, U - > {}; + >; } } /* namespace ostd */ diff --git a/ostd/tuple.hh b/ostd/tuple.hh index ea466fc..ac6375d 100644 --- a/ostd/tuple.hh +++ b/ostd/tuple.hh @@ -218,13 +218,13 @@ namespace detail { {} template>::value + TupleConstructible> >> TupleBase(T &&t): TupleLeaf(forward< TupleElement> >(get(t)))... {} template>::value + TupleConvertible> >> TupleBase(AllocatorArg, const Alloc &a, T &&t): TupleLeaf(UsesAllocatorConstructor< A, Alloc, TupleElement> @@ -232,7 +232,7 @@ namespace detail { {} template - EnableIf>::value, TupleBase &> + EnableIf>, TupleBase &> operator=(T &&t) { tuple_swallow(TupleLeaf::operator=(forward< TupleElement> @@ -302,7 +302,7 @@ public: (sizeof...(T) < sizeof...(A)) ? sizeof...(T) : sizeof...(A) > - >::value && + > && detail::TupleAllDefaultConstructible< detail::MakeTupleTypes - >::value && + > && !detail::TupleConvertible< Tuple, detail::MakeTupleTypes - >::value && + > && detail::TupleAllDefaultConstructible< detail::MakeTupleTypes - >::value && + > && detail::TupleAllDefaultConstructible< detail::MakeTupleTypes(t)...) {} template::value, bool + detail::TupleConvertible, bool > = true> Tuple(T &&t): p_base(forward(t)) {} template::value && - !detail::TupleConvertible::value, bool + detail::TupleConstructible && + !detail::TupleConvertible, bool > = true> Tuple(T &&t): p_base(forward(t)) {} template::value + detail::TupleConvertible >> Tuple(AllocatorArg, const Alloc &a, T &&t): p_base(allocator_arg, a, forward(t)) {} - template::value - >> Tuple &operator=(T &&t) { + template>> + Tuple &operator=(T &&t) { p_base.operator=(forward(t)); return *this; }