convert IsSame to template variable

master
Daniel Kolesa 2016-01-12 22:24:40 +00:00
parent 7edf3e1d4a
commit 9b11c1d319
13 changed files with 72 additions and 77 deletions

View File

@ -619,7 +619,7 @@ namespace detail {
template<typename R, typename P> using FilterPred template<typename R, typename P> using FilterPred
= EnableIf<IsSame< = EnableIf<IsSame<
decltype(declval<P>()(declval<RangeReference<R>>())), bool decltype(declval<P>()(declval<RangeReference<R>>())), bool
>::value, P>; >, P>;
} }
template<typename R, typename P> template<typename R, typename P>

View File

@ -288,7 +288,7 @@ template <typename T> inline T kill_dependency(T v) {
} }
namespace detail { namespace detail {
template<typename T, bool = IsIntegral<T> && !IsSame<T, bool>::value> template<typename T, bool = IsIntegral<T> && !IsSame<T, bool>>
struct Atomic { struct Atomic {
mutable AtomicBase<T> p_a; mutable AtomicBase<T> p_a;
@ -656,13 +656,13 @@ inline bool atomic_compare_exchange_strong_explicit(Atomic<T> *a, T *e,
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_add(volatile Atomic<T> *a, T op) { atomic_fetch_add(volatile Atomic<T> *a, T op) {
return a->fetch_add(op); return a->fetch_add(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_add(Atomic<T> *a, T op) { atomic_fetch_add(Atomic<T> *a, T op) {
return a->fetch_add(op); return a->fetch_add(op);
} }
@ -678,14 +678,14 @@ inline T *atomic_fetch_add(Atomic<T *> *a, Ptrdiff op) {
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_add_explicit(volatile Atomic<T> *a, T op, atomic_fetch_add_explicit(volatile Atomic<T> *a, T op,
MemoryOrder ord) { MemoryOrder ord) {
return a->fetch_add(op, ord); return a->fetch_add(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_add_explicit(Atomic<T> *a, T op, MemoryOrder ord) { atomic_fetch_add_explicit(Atomic<T> *a, T op, MemoryOrder ord) {
return a->fetch_add(op, ord); return a->fetch_add(op, ord);
} }
@ -703,13 +703,13 @@ inline T *atomic_fetch_add_explicit(Atomic<T *> *a, Ptrdiff op,
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_sub(volatile Atomic<T> *a, T op) { atomic_fetch_sub(volatile Atomic<T> *a, T op) {
return a->fetch_sub(op); return a->fetch_sub(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_sub(Atomic<T> *a, T op) { atomic_fetch_sub(Atomic<T> *a, T op) {
return a->fetch_sub(op); return a->fetch_sub(op);
} }
@ -725,14 +725,14 @@ inline T *atomic_fetch_sub(Atomic<T *> *a, Ptrdiff op) {
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_sub_explicit(volatile Atomic<T> *a, T op, atomic_fetch_sub_explicit(volatile Atomic<T> *a, T op,
MemoryOrder ord) { MemoryOrder ord) {
return a->fetch_sub(op, ord); return a->fetch_sub(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_sub_explicit(Atomic<T> *a, T op, MemoryOrder ord) { atomic_fetch_sub_explicit(Atomic<T> *a, T op, MemoryOrder ord) {
return a->fetch_sub(op, ord); return a->fetch_sub(op, ord);
} }
@ -750,76 +750,76 @@ inline T *atomic_fetch_sub_explicit(Atomic<T *> *a, Ptrdiff op,
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_and(volatile Atomic<T> *a, T op) { atomic_fetch_and(volatile Atomic<T> *a, T op) {
return a->fetch_and(op); return a->fetch_and(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_and(Atomic<T> *a, T op) { atomic_fetch_and(Atomic<T> *a, T op) {
return a->fetch_and(op); return a->fetch_and(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_and_explicit(volatile Atomic<T> *a, T op, atomic_fetch_and_explicit(volatile Atomic<T> *a, T op,
MemoryOrder ord) { MemoryOrder ord) {
return a->fetch_and(op, ord); return a->fetch_and(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_and_explicit(Atomic<T> *a, T op, MemoryOrder ord) { atomic_fetch_and_explicit(Atomic<T> *a, T op, MemoryOrder ord) {
return a->fetch_and(op, ord); return a->fetch_and(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_or(volatile Atomic<T> *a, T op) { atomic_fetch_or(volatile Atomic<T> *a, T op) {
return a->fetch_or(op); return a->fetch_or(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_or(Atomic<T> *a, T op) { atomic_fetch_or(Atomic<T> *a, T op) {
return a->fetch_or(op); return a->fetch_or(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_or_explicit(volatile Atomic<T> *a, T op, atomic_fetch_or_explicit(volatile Atomic<T> *a, T op,
MemoryOrder ord) { MemoryOrder ord) {
return a->fetch_or(op, ord); return a->fetch_or(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_or_explicit(Atomic<T> *a, T op, MemoryOrder ord) { atomic_fetch_or_explicit(Atomic<T> *a, T op, MemoryOrder ord) {
return a->fetch_or(op, ord); return a->fetch_or(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_xor(volatile Atomic<T> *a, T op) { atomic_fetch_xor(volatile Atomic<T> *a, T op) {
return a->fetch_xor(op); return a->fetch_xor(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_xor(Atomic<T> *a, T op) { atomic_fetch_xor(Atomic<T> *a, T op) {
return a->fetch_xor(op); return a->fetch_xor(op);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_xor_explicit(volatile Atomic<T> *a, T op, atomic_fetch_xor_explicit(volatile Atomic<T> *a, T op,
MemoryOrder ord) { MemoryOrder ord) {
return a->fetch_xor(op, ord); return a->fetch_xor(op, ord);
} }
template <typename T> template <typename T>
inline EnableIf<IsIntegral<T> && !IsSame<T, bool>::value, T> inline EnableIf<IsIntegral<T> && !IsSame<T, bool>, T>
atomic_fetch_xor_explicit(Atomic<T> *a, T op, MemoryOrder ord) { atomic_fetch_xor_explicit(Atomic<T> *a, T op, MemoryOrder ord) {
return a->fetch_xor(op, ord); return a->fetch_xor(op, ord);
} }

View File

@ -401,7 +401,7 @@ protected:
template<typename T, typename R, typename = EnableIf< template<typename T, typename R, typename = EnableIf<
IsSame<decltype(declval<const T &>() IsSame<decltype(declval<const T &>()
.to_format(declval<R &>(), declval<const FormatSpec &>())), bool .to_format(declval<R &>(), declval<const FormatSpec &>())), bool
>::value >
>> inline bool to_format(const T &v, R &writer, const FormatSpec &fs) { >> inline bool to_format(const T &v, R &writer, const FormatSpec &fs) {
return v.to_format(writer, fs); return v.to_format(writer, fs);
} }
@ -692,11 +692,9 @@ namespace detail {
return detail::write_u(writer, this, false, val); return detail::write_u(writer, this, false, val);
} }
template<typename R, typename T, template<typename R, typename T, bool Long = IsSame<T, ldouble>>
bool Long = IsSame<T, ldouble>::value Ptrdiff write(R &writer, bool, T val, EnableIf<IsFloatingPoint<T>, bool>
> Ptrdiff write(R &writer, bool, T val, EnableIf< = true) {
IsFloatingPoint<T>, bool
> = true) {
char buf[16], rbuf[128]; char buf[16], rbuf[128];
char fmtspec[Long + 1]; char fmtspec[Long + 1];

View File

@ -48,7 +48,7 @@ OSTD_DEFINE_BINARY_OP(BitXor, ^, T)
#undef OSTD_DEFINE_BINARY_OP #undef OSTD_DEFINE_BINARY_OP
namespace detail { namespace detail {
template<typename T, bool = IsSame<RemoveConst<T>, char>::value> template<typename T, bool = IsSame<RemoveConst<T>, char>>
struct CharEqual { struct CharEqual {
using FirstArgument = T *; using FirstArgument = T *;
using SecondArgument = T *; using SecondArgument = T *;
@ -372,7 +372,7 @@ template<> struct ToHash<ldouble>: detail::ScalarHash<ldouble> {
}; };
namespace detail { namespace detail {
template<typename T, bool = IsSame<RemoveConst<T>, char>::value> template<typename T, bool = IsSame<RemoveConst<T>, char>>
struct ToHashPtr { struct ToHashPtr {
using Argument = T *; using Argument = T *;
using Result = Size; using Result = Size;

View File

@ -56,7 +56,7 @@ public:
template<typename U> template<typename U>
HashRange(const HashRange<U> &v, EnableIf< HashRange(const HashRange<U> &v, EnableIf<
IsSame<RemoveCv<T>, RemoveCv<U>>::value && IsSame<RemoveCv<T>, RemoveCv<U>> &&
IsConvertible<U *, T *>::value, bool IsConvertible<U *, T *>::value, bool
> = true): p_node((Chain *)v.p_node) {} > = true): p_node((Chain *)v.p_node) {}
@ -95,7 +95,7 @@ public:
template<typename U> template<typename U>
BucketRange(const BucketRange<U> &v, EnableIf< BucketRange(const BucketRange<U> &v, EnableIf<
IsSame<RemoveCv<T>, RemoveCv<U>>::value && IsSame<RemoveCv<T>, RemoveCv<U>> &&
IsConvertible<U *, T *>::value, bool IsConvertible<U *, T *>::value, bool
> = true): p_node((Chain *)v.p_node), p_end((Chain *)v.p_end) {} > = true): p_node((Chain *)v.p_node), p_end((Chain *)v.p_end) {}

View File

@ -95,9 +95,9 @@ public:
static_assert(!IsReference<T>, static_assert(!IsReference<T>,
"Initialization of Maybe with a reference type is not allowed."); "Initialization of Maybe with a reference type is not allowed.");
static_assert(!IsSame<RemoveCv<T>, InPlace>::value, static_assert(!IsSame<RemoveCv<T>, InPlace>,
"Initialization of Maybe with InPlace is not allowed."); "Initialization of Maybe with InPlace is not allowed.");
static_assert(!IsSame<RemoveCv<T>, Nothing>::value, static_assert(!IsSame<RemoveCv<T>, Nothing>,
"Initialization of Maybe with Nothing is not allowed."); "Initialization of Maybe with Nothing is not allowed.");
static_assert(IsObject<T>, static_assert(IsObject<T>,
"Initialization of Maybe with non-object type is not allowed."); "Initialization of Maybe with non-object type is not allowed.");
@ -159,7 +159,7 @@ public:
} }
template<typename U, typename = EnableIf< template<typename U, typename = EnableIf<
IsSame<RemoveReference<U>, Value>::value && IsSame<RemoveReference<U>, Value> &&
IsConstructible<Value, U> && IsAssignable<Value &, U> IsConstructible<Value, U> && IsAssignable<Value &, U>
>> >>
Maybe &operator=(U &&v) { Maybe &operator=(U &&v) {

View File

@ -264,7 +264,7 @@ public:
Box(Box<TT, DD> &&u, EnableIf<!IsArray<TT> Box(Box<TT, DD> &&u, EnableIf<!IsArray<TT>
&& IsConvertible<typename Box<TT, DD>::Pointer, Pointer>::value && IsConvertible<typename Box<TT, DD>::Pointer, Pointer>::value
&& IsConvertible<DD, D>::value && IsConvertible<DD, D>::value
&& (!IsReference<D> || IsSame<D, DD>::value) && (!IsReference<D> || IsSame<D, DD>)
> = Nat()): p_stor(u.release(), forward<DD>(u.get_deleter())) {} > = Nat()): p_stor(u.release(), forward<DD>(u.get_deleter())) {}
Box &operator=(Box &&u) { Box &operator=(Box &&u) {
@ -327,13 +327,13 @@ namespace detail {
template<typename T, typename U, bool = IsSame< template<typename T, typename U, bool = IsSame<
RemoveCv<PointerElement<T>>, RemoveCv<PointerElement<T>>,
RemoveCv<PointerElement<U>> RemoveCv<PointerElement<U>>
>::value> struct SameOrLessCvQualifiedBase: IsConvertible<T, U> {}; >> struct SameOrLessCvQualifiedBase: IsConvertible<T, U> {};
template<typename T, typename U> template<typename T, typename U>
struct SameOrLessCvQualifiedBase<T, U, false>: False {}; struct SameOrLessCvQualifiedBase<T, U, false>: False {};
template<typename T, typename U, bool = IsPointer<T> template<typename T, typename U, bool = IsPointer<T>
|| IsSame<T, U>::value || detail::HasElement<T>::value || IsSame<T, U> || detail::HasElement<T>::value
> struct SameOrLessCvQualified: SameOrLessCvQualifiedBase<T, U> {}; > struct SameOrLessCvQualified: SameOrLessCvQualifiedBase<T, U> {};
template<typename T, typename U> template<typename T, typename U>
@ -393,7 +393,7 @@ public:
&& detail::SameOrLessCvQualified<typename Box<TT, DD>::Pointer, && detail::SameOrLessCvQualified<typename Box<TT, DD>::Pointer,
Pointer>::value Pointer>::value
&& IsConvertible<DD, D>::value && IsConvertible<DD, D>::value
&& (!IsReference<D> || IsSame<D, DD>::value)> = Nat() && (!IsReference<D> || IsSame<D, DD>)> = Nat()
): p_stor(u.release(), forward<DD>(u.get_deleter())) {} ): p_stor(u.release(), forward<DD>(u.get_deleter())) {}
Box &operator=(Box &&u) { Box &operator=(Box &&u) {
@ -885,7 +885,7 @@ namespace detail {
IsSame<decltype(allocate_hint_test(declval<A>(), IsSame<decltype(allocate_hint_test(declval<A>(),
declval<S>(), declval<S>(),
declval<CVP>())), True declval<CVP>())), True
>::value >
> {}; > {};
template<typename A> template<typename A>
@ -938,7 +938,7 @@ namespace detail {
IsSame< decltype(construct_test(declval<A>(), IsSame< decltype(construct_test(declval<A>(),
declval<T>(), declval<T>(),
declval<Args>()...)), True declval<Args>()...)), True
>::value >
> {}; > {};
template<typename A, typename T, typename ...Args> template<typename A, typename T, typename ...Args>
@ -969,8 +969,7 @@ namespace detail {
template<typename A, typename P> template<typename A, typename P>
struct DestroyTest: IntegralConstant<bool, struct DestroyTest: IntegralConstant<bool,
IsSame<decltype(destroy_test(declval<A>(), declval<P>())), True IsSame<decltype(destroy_test(declval<A>(), declval<P>())), True>
>::value
> {}; > {};
template<typename A, typename T> template<typename A, typename T>
@ -1000,8 +999,7 @@ namespace detail {
template<typename A> template<typename A>
struct AllocMaxSizeTest: IntegralConstant<bool, struct AllocMaxSizeTest: IntegralConstant<bool,
IsSame<decltype(alloc_max_size_test(declval<A &>())), True IsSame<decltype(alloc_max_size_test(declval<A &>())), True>
>::value
> {}; > {};
template<typename A> template<typename A>
@ -1031,8 +1029,7 @@ namespace detail {
template<typename A> template<typename A>
struct AllocCopyTest: IntegralConstant<bool, struct AllocCopyTest: IntegralConstant<bool,
IsSame<decltype(alloc_copy_test(declval<A &>())), True IsSame<decltype(alloc_copy_test(declval<A &>())), True>
>::value
> {}; > {};
template<typename A> template<typename A>

View File

@ -210,7 +210,7 @@ class StringBase {
template<typename R> template<typename R>
void ctor_from_range(R &range, EnableIf< void ctor_from_range(R &range, EnableIf<
IsFiniteRandomAccessRange<R>::value && IsFiniteRandomAccessRange<R>::value &&
IsSame<T, RemoveCv<RangeValue<R>>>::value, bool IsSame<T, RemoveCv<RangeValue<R>>>, bool
> = true) { > = true) {
if (range.empty()) return; if (range.empty()) return;
RangeSize<R> l = range.size(); RangeSize<R> l = range.size();
@ -223,7 +223,7 @@ class StringBase {
template<typename R> template<typename R>
void ctor_from_range(R &range, EnableIf< void ctor_from_range(R &range, EnableIf<
!IsFiniteRandomAccessRange<R>::value || !IsFiniteRandomAccessRange<R>::value ||
!IsSame<T, RemoveCv<RangeValue<R>>>::value, bool !IsSame<T, RemoveCv<RangeValue<R>>>, bool
> = true) { > = true) {
if (range.empty()) return; if (range.empty()) return;
Size i = 0; Size i = 0;
@ -669,7 +669,7 @@ namespace detail {
template<typename T, typename R> template<typename T, typename R>
auto test_stringify(int) -> auto test_stringify(int) ->
decltype(IsSame<decltype(declval<T>().stringify()), String>()); IntegralConstant<bool, IsSame<decltype(declval<T>().stringify()), String>>;
template<typename T, typename R> template<typename T, typename R>
static True test_stringify(decltype(declval<const T &>().to_string static True test_stringify(decltype(declval<const T &>().to_string

View File

@ -53,18 +53,16 @@ namespace detail {
"attempt to default construct a reference element in a tuple"); "attempt to default construct a reference element in a tuple");
} }
template<typename T, template<typename T, typename = EnableIf<And<
typename = EnableIf<And<Not<IsSame<Decay<T>, TupleLeaf>>, Not<IntegralConstant<bool, IsSame<Decay<T>, TupleLeaf>>>,
IntegralConstant<bool, IntegralConstant<bool, IsConstructible<H, T>>
IsConstructible<H, T> >::value>>
>>::value>>
explicit TupleLeaf(T &&t): p_value(forward<T>(t)) { explicit TupleLeaf(T &&t): p_value(forward<T>(t)) {
static_assert(!IsReference<H> || static_assert(!IsReference<H> ||
(IsLvalueReference<H> && (IsLvalueReference<H> &&
(IsLvalueReference<T> || (IsLvalueReference<T> ||
IsSame<RemoveReference<T>, IsSame<RemoveReference<T>,
ReferenceWrapper<RemoveReference<H>> ReferenceWrapper<RemoveReference<H>>>)) ||
>::value)) ||
(IsRvalueReference<H> && (IsRvalueReference<H> &&
!IsLvalueReference<T>), !IsLvalueReference<T>),
"attempt to construct a reference element in a tuple with an rvalue"); "attempt to construct a reference element in a tuple with an rvalue");
@ -77,8 +75,7 @@ namespace detail {
(IsLvalueReference<H> && (IsLvalueReference<H> &&
(IsLvalueReference<T> || (IsLvalueReference<T> ||
IsSame<RemoveReference<T>, IsSame<RemoveReference<T>,
ReferenceWrapper<RemoveReference<H>> ReferenceWrapper<RemoveReference<H>>>)),
>::value)),
"attempt to construct a reference element in a tuple with an rvalue"); "attempt to construct a reference element in a tuple with an rvalue");
} }
@ -89,8 +86,7 @@ namespace detail {
(IsLvalueReference<H> && (IsLvalueReference<H> &&
(IsLvalueReference<T> || (IsLvalueReference<T> ||
IsSame<RemoveReference<T>, IsSame<RemoveReference<T>,
ReferenceWrapper<RemoveReference<H>> ReferenceWrapper<RemoveReference<H>>>)),
>::value)),
"attempt to construct a reference element in a tuple with an rvalue"); "attempt to construct a reference element in a tuple with an rvalue");
} }
@ -101,8 +97,7 @@ namespace detail {
(IsLvalueReference<H> && (IsLvalueReference<H> &&
(IsLvalueReference<T> || (IsLvalueReference<T> ||
IsSame<RemoveReference<T>, IsSame<RemoveReference<T>,
ReferenceWrapper<RemoveReference<H>> ReferenceWrapper<RemoveReference<H>>>)),
>::value)),
"attempt to construct a reference element in a tuple with an rvalue"); "attempt to construct a reference element in a tuple with an rvalue");
} }
@ -143,7 +138,7 @@ namespace detail {
template<typename T, template<typename T,
typename = EnableIf<And< typename = EnableIf<And<
Not<IsSame<Decay<T>, TupleLeaf>>, Not<IntegralConstant<bool, IsSame<Decay<T>, TupleLeaf>>>,
IntegralConstant<bool, IsConstructible<H, T>> IntegralConstant<bool, IsConstructible<H, T>>
>::value> >::value>
> explicit TupleLeaf(T &&t): H(forward<T>(t)) {} > explicit TupleLeaf(T &&t): H(forward<T>(t)) {}
@ -187,8 +182,8 @@ namespace detail {
template<typename ...A> template<typename ...A>
inline void tuple_swallow(A &&...) {} inline void tuple_swallow(A &&...) {}
template<bool ...A> template<bool ...A> struct TupleAll:
struct TupleAll: IsSame<TupleAll<A...>, TupleAll<(A, true)...>> {}; IntegralConstant<bool, IsSame<TupleAll<A...>, TupleAll<(A, true)...>>> {};
template<typename T> template<typename T>
struct TupleAllDefaultConstructible; struct TupleAllDefaultConstructible;

View File

@ -110,18 +110,23 @@ struct Not: IntegralConstant<bool, !T::Type::value> {};
/* type equality */ /* type equality */
template<typename, typename> struct IsSame : False {}; namespace detail {
template<typename T > struct IsSame<T, T>: True {}; template<typename, typename> struct IsSameBase : False {};
template<typename T > struct IsSameBase<T, T>: True {};
}
template<typename T, typename U>
static constexpr bool IsSame = detail::IsSameBase<T, U>::value;
/* is void */ /* is void */
template<typename T> template<typename T>
static constexpr bool IsVoid = IsSame<RemoveCv<T>, void>::value; static constexpr bool IsVoid = IsSame<RemoveCv<T>, void>;
/* is null pointer */ /* is null pointer */
template<typename T> template<typename T>
static constexpr bool IsNullPointer = IsSame<RemoveCv<T>, Nullptr>::value; static constexpr bool IsNullPointer = IsSame<RemoveCv<T>, Nullptr>;
/* is integer */ /* is integer */
@ -326,12 +331,12 @@ template<typename T> static constexpr bool IsAbstract = __is_abstract(T);
/* is const */ /* is const */
template<typename T> template<typename T>
static constexpr bool IsConst = IsSame<T, const T>::value; static constexpr bool IsConst = IsSame<T, const T>;
/* is volatile */ /* is volatile */
template<typename T> template<typename T>
static constexpr bool IsVolatile = IsSame<T, volatile T>::value; static constexpr bool IsVolatile = IsSame<T, volatile T>;
/* is empty */ /* is empty */

View File

@ -260,7 +260,7 @@ TupleElement<I, Pair<T, U>> &&get(Pair<T, U> &&p) {
namespace detail { namespace detail {
template<typename T, typename U, template<typename T, typename U,
bool = IsSame<RemoveCv<T>, RemoveCv<U>>::value, bool = IsSame<RemoveCv<T>, RemoveCv<U>>,
bool = IsEmpty<T>, bool = IsEmpty<U> bool = IsEmpty<T>, bool = IsEmpty<U>
> struct CompressedPairSwitch; > struct CompressedPairSwitch;

View File

@ -36,7 +36,7 @@ class Vector {
template<typename R> template<typename R>
void ctor_from_range(R &range, EnableIf< void ctor_from_range(R &range, EnableIf<
IsFiniteRandomAccessRange<R>::value && IsPod<T> && IsFiniteRandomAccessRange<R>::value && IsPod<T> &&
IsSame<T, RemoveCv<RangeValue<R>>>::value, bool IsSame<T, RemoveCv<RangeValue<R>>>, bool
> = true) { > = true) {
RangeSize<R> l = range.size(); RangeSize<R> l = range.size();
reserve(l); reserve(l);
@ -47,7 +47,7 @@ class Vector {
template<typename R> template<typename R>
void ctor_from_range(R &range, EnableIf< void ctor_from_range(R &range, EnableIf<
!IsFiniteRandomAccessRange<R>::value || !IsPod<T> || !IsFiniteRandomAccessRange<R>::value || !IsPod<T> ||
!IsSame<T, RemoveCv<RangeValue<R>>>::value, bool !IsSame<T, RemoveCv<RangeValue<R>>>, bool
> = true) { > = true) {
Size i = 0; Size i = 0;
for (; !range.empty(); range.pop_front()) { for (; !range.empty(); range.pop_front()) {

View File

@ -77,8 +77,8 @@ int main() {
auto x = make_pair(5, 3.14f); auto x = make_pair(5, 3.14f);
assert((IsSame<decltype(x.first), int>::value)); assert((IsSame<decltype(x.first), int>));
assert((IsSame<decltype(x.second), float>::value)); assert((IsSame<decltype(x.second), float>));
assert(x.first == 5); assert(x.first == 5);
assert(x.second == 3.14f); assert(x.second == 3.14f);