more template var conversions

master
Daniel Kolesa 2016-01-12 22:09:40 +00:00
parent 697b135157
commit 7edf3e1d4a
10 changed files with 44 additions and 41 deletions

View File

@ -627,7 +627,7 @@ namespace detail {
/* any string value */
template<typename R, typename T>
Ptrdiff write(R &writer, bool escape, const T &val, EnableIf<
IsConstructible<ConstCharRange, const T &>::value, bool
IsConstructible<ConstCharRange, const T &>, bool
> = true) {
if (this->spec() != 's') {
assert(false && "cannot print strings with the given spec");
@ -729,7 +729,7 @@ namespace detail {
/* pointer value */
template<typename R, typename T>
Ptrdiff write(R &writer, bool, T *val, EnableIf<
!IsConstructible<ConstCharRange, T *>::value, bool
!IsConstructible<ConstCharRange, T *>, bool
> = true) {
if (this->p_spec == 's') {
this->p_spec = 'x';
@ -742,7 +742,7 @@ namespace detail {
template<typename R, typename T>
Ptrdiff write(R &writer, bool, const T &val, EnableIf<
!IsArithmetic<T> &&
!IsConstructible<ConstCharRange, const T &>::value &&
!IsConstructible<ConstCharRange, const T &> &&
FmtTostrTest<T>::value &&
!FmtTofmtTest<T, TostrRange<R>>::value, bool
> = true) {
@ -767,7 +767,7 @@ namespace detail {
template<typename R, typename T>
Ptrdiff write(R &, bool, const T &, EnableIf<
!IsArithmetic<T> &&
!IsConstructible<ConstCharRange, const T &>::value &&
!IsConstructible<ConstCharRange, const T &> &&
!FmtTostrTest<T>::value &&
!FmtTofmtTest<T, TostrRange<R>>::value, bool
> = true) {

View File

@ -513,7 +513,7 @@ namespace detail {
struct FunctorInPlace {
static constexpr bool value = sizeof(T) <= sizeof(FunctorData)
&& (alignof(FunctorData) % alignof(T)) == 0
&& IsMoveConstructible<T>::value;
&& IsMoveConstructible<T>;
};
struct FunctionManager;
@ -929,8 +929,8 @@ namespace detail {
using Type = typename DcLambdaTypes<F>::Ptr;
};
template<typename F, bool = IsDefaultConstructible<F>::value &&
IsMoveConstructible<F>::value
template<typename F, bool = IsDefaultConstructible<F> &&
IsMoveConstructible<F>
> struct DcFuncTypeObj {
using Type = typename DcFuncTypeObjBase<F>::Type;
};

View File

@ -218,7 +218,7 @@ namespace detail {
template<typename T, typename ...TT, typename U, typename ...UU>
struct TupleConstructibleBase<TupleTypes<T, TT...>, TupleTypes<U, UU...>>:
IntegralConstant<bool, IsConstructible<U, T>::value &&
IntegralConstant<bool, IsConstructible<U, T> &&
TupleConstructibleBase<TupleTypes<TT...>,
TupleTypes<UU...>>::value> {};
@ -251,7 +251,7 @@ namespace detail {
template<typename T, typename ...TT, typename U, typename ...UU>
struct TupleAssignableBase<TupleTypes<T, TT...>, TupleTypes<U, UU...>>:
IntegralConstant<bool, IsAssignable<U &, T>::value &&
IntegralConstant<bool, IsAssignable<U &, T> &&
TupleAssignableBase<TupleTypes<TT...>,
TupleTypes<UU...>>::value> {};

View File

@ -140,7 +140,7 @@ namespace detail {
template<typename T>
inline void write_impl(const T &v, EnableIf<
!IsConstructible<ConstCharRange, const T &>::value, IoNat
!IsConstructible<ConstCharRange, const T &>, IoNat
> = IoNat()) {
write(ostd::to_string(v));
}

View File

@ -111,13 +111,12 @@ public:
constexpr Maybe(const Value &v): Base(v) {}
constexpr Maybe(Value &&v): Base(move(v)) {}
template<typename ...A, typename = EnableIf<
IsConstructible<T, A...>::value>>
template<typename ...A, typename = EnableIf<IsConstructible<T, A...>>>
constexpr explicit Maybe(InPlace, A &&...args): Base(in_place,
forward<A>(args)...) {}
template<typename U, typename ...A, typename = EnableIf<
IsConstructible<T, std::initializer_list<U> &, A...>::value>>
IsConstructible<T, std::initializer_list<U> &, A...>>>
constexpr explicit
Maybe(InPlace, std::initializer_list<U> il, A &&...args):
Base(in_place, il, forward<A>(args)...) {}
@ -161,8 +160,7 @@ public:
template<typename U, typename = EnableIf<
IsSame<RemoveReference<U>, Value>::value &&
IsConstructible<Value, U>::value &&
IsAssignable<Value &, U>::value
IsConstructible<Value, U> && IsAssignable<Value &, U>
>>
Maybe &operator=(U &&v) {
if (this->p_engaged) {
@ -174,9 +172,7 @@ public:
return *this;
}
template<typename ...A, typename = EnableIf<
IsConstructible<Value, A...>::value
>>
template<typename ...A, typename = EnableIf<IsConstructible<Value, A...>>>
void emplace(A &&...args) {
*this = nothing;
::new(address_of(this->p_value)) Value(forward<A>(args)...);
@ -184,7 +180,7 @@ public:
}
template<typename U, typename ...A, typename = EnableIf<
IsConstructible<Value, std::initializer_list<U> &, A...>::value
IsConstructible<Value, std::initializer_list<U> &, A...>
>>
void emplace(std::initializer_list<U> il, A &&...args) {
*this = nothing;
@ -221,7 +217,7 @@ public:
template<typename U>
constexpr Value value_or(U &&v) const & {
static_assert(IsCopyConstructible<Value>::value,
static_assert(IsCopyConstructible<Value>,
"Maybe<T>::value_or: T must be copy constructible");
static_assert(IsConvertible<U, Value>::value,
"Maybe<T>::value_or: U must be convertible to T");
@ -230,7 +226,7 @@ public:
template<typename U>
Value value_or(U &&v) && {
static_assert(IsMoveConstructible<Value>::value,
static_assert(IsMoveConstructible<Value>,
"Maybe<T>::value_or: T must be copy constructible");
static_assert(IsConvertible<U, Value>::value,
"Maybe<T>::value_or: U must be convertible to T");

View File

@ -276,7 +276,7 @@ public:
template<typename TT, typename DD>
EnableIf<!IsArray<TT>
&& IsConvertible<typename Box<TT, DD>::Pointer, Pointer>::value
&& IsAssignable<D &, DD &&>::value,
&& IsAssignable<D &, DD &&>,
Box &
> operator=(Box<TT, DD> &&u) {
reset(u.release());
@ -406,7 +406,7 @@ public:
EnableIf<IsArray<TT>
&& detail::SameOrLessCvQualified<typename Box<TT, DD>::Pointer,
Pointer>::value
&& IsAssignable<D &, DD &&>::value,
&& IsAssignable<D &, DD &&>,
Box &
> operator=(Box<TT, DD> &&u) {
reset(u.release());
@ -1088,7 +1088,7 @@ namespace detail {
static constexpr bool ua = UsesAllocator<T, A>::value;
static constexpr bool ic = IsConstructible<
T, AllocatorArg, A, Args...
>::value;
>;
static constexpr int value = ua ? (2 - ic) : 0;
};
}

View File

@ -69,7 +69,7 @@ private:
template<typename T>
inline bool write_impl(const T &v, EnableIf<
!IsConstructible<ConstCharRange, const T &>::value, StNat
!IsConstructible<ConstCharRange, const T &>, StNat
> = StNat()) {
return write(ostd::to_string(v));
}

View File

@ -55,7 +55,9 @@ namespace detail {
template<typename T,
typename = EnableIf<And<Not<IsSame<Decay<T>, TupleLeaf>>,
IsConstructible<H, T>>::value>>
IntegralConstant<bool,
IsConstructible<H, T>
>>::value>>
explicit TupleLeaf(T &&t): p_value(forward<T>(t)) {
static_assert(!IsReference<H> ||
(IsLvalueReference<H> &&
@ -142,7 +144,7 @@ namespace detail {
template<typename T,
typename = EnableIf<And<
Not<IsSame<Decay<T>, TupleLeaf>>,
IsConstructible<H, T>
IntegralConstant<bool, IsConstructible<H, T>>
>::value>
> explicit TupleLeaf(T &&t): H(forward<T>(t)) {}
@ -193,7 +195,7 @@ namespace detail {
template<typename ...A>
struct TupleAllDefaultConstructible<TupleTypes<A...>>:
TupleAll<IsDefaultConstructible<A>::value...> {};
TupleAll<IsDefaultConstructible<A>...> {};
}
/* tuple implementation */
@ -284,7 +286,7 @@ class Tuple {
public:
template<bool D = true, typename = EnableIf<
detail::TupleAll<(D && IsDefaultConstructible<A>::value)...>::value
detail::TupleAll<(D && IsDefaultConstructible<A>)...>::value
>> Tuple() {}
explicit Tuple(const A &...t):

View File

@ -488,23 +488,26 @@ namespace detail {
} /* namespace detail */
template<typename T, typename ...A>
struct IsConstructible: detail::Ctible<T, A...> {};
static constexpr bool IsConstructible = detail::Ctible<T, A...>::value;
/* is default constructible */
template<typename T> struct IsDefaultConstructible: IsConstructible<T> {};
template<typename T>
static constexpr bool IsDefaultConstructible = IsConstructible<T>;
/* is copy constructible */
template<typename T> struct IsCopyConstructible: IsConstructible<T,
template<typename T>
static constexpr bool IsCopyConstructible = IsConstructible<T,
AddLvalueReference<AddConst<T>>
> {};
>;
/* is move constructible */
template<typename T> struct IsMoveConstructible: IsConstructible<T,
template<typename T>
static constexpr bool IsMoveConstructible = IsConstructible<T,
AddRvalueReference<T>
> {};
>;
/* is assignable */
@ -525,21 +528,23 @@ namespace detail {
} /* namespace detail */
template<typename T, typename U>
struct IsAssignable: detail::IsAssignableBase<T, U> {};
static constexpr bool IsAssignable = detail::IsAssignableBase<T, U>::value;
/* is copy assignable */
template<typename T> struct IsCopyAssignable: IsAssignable<
template<typename T>
static constexpr bool IsCopyAssignable = IsAssignable<
AddLvalueReference<T>,
AddLvalueReference<AddConst<T>>
> {};
>;
/* is move assignable */
template<typename T> struct IsMoveAssignable: IsAssignable<
template<typename T>
static constexpr bool IsMoveAssignable = IsAssignable<
AddLvalueReference<T>,
const AddRvalueReference<T>
> {};
>;
/* is destructible */

View File

@ -5,7 +5,7 @@ import subprocess as sp
# configuration - you can modify this
COMPILER = "c++"
COMPILER = "clang++-devel"
CXXFLAGS = [
"-std=c++14",
"-Wall", "-Wextra",