forked from OctaForge/libostd
cleanups
This commit is contained in:
parent
5902299a1d
commit
305d3e54f6
|
@ -696,14 +696,10 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename, typename>
|
template<typename, typename>
|
||||||
struct IsValidFunctor {
|
constexpr bool IsValidFunctor = false;
|
||||||
static constexpr bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
struct IsValidFunctor<Function<R(A...)>, R(A...)> {
|
constexpr bool IsValidFunctor<Function<R(A...)>, R(A...)> = false;
|
||||||
static constexpr bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T func_to_functor(T &&f) {
|
T func_to_functor(T &&f) {
|
||||||
|
@ -722,19 +718,17 @@ namespace detail {
|
||||||
return mem_fn(f);
|
return mem_fn(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename R, typename ...A>
|
struct ValidFunctorNat {};
|
||||||
struct IsValidFunctor<T, R(A...)> {
|
|
||||||
struct Nat {};
|
|
||||||
|
|
||||||
template<typename U>
|
template<typename U, typename ...A>
|
||||||
static decltype(func_to_functor(declval<U>()) (declval<A>()...))
|
static decltype(func_to_functor(declval<U>()) (declval<A>()...))
|
||||||
test(U *);
|
valid_functor_test(U *);
|
||||||
template<typename>
|
template<typename, typename ...>
|
||||||
static Nat test(...);
|
static ValidFunctorNat valid_functor_test(...);
|
||||||
|
|
||||||
static constexpr bool value
|
template<typename T, typename R, typename ...A>
|
||||||
= IsConvertible<decltype(test<T>(nullptr)), R>;
|
constexpr bool IsValidFunctor<T, R(A...)>
|
||||||
};
|
= IsConvertible<decltype(valid_functor_test<T, A...>(nullptr)), R>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using FunctorType = decltype(func_to_functor(declval<T>()));
|
using FunctorType = decltype(func_to_functor(declval<T>()));
|
||||||
|
@ -755,7 +749,7 @@ struct Function<R(Args...)>: detail::FunctionBase<R, Args...> {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename = EnableIf<
|
template<typename T, typename = EnableIf<
|
||||||
detail::IsValidFunctor<T, R(Args...)>::value
|
detail::IsValidFunctor<T, R(Args...)>
|
||||||
>> Function(T f) {
|
>> Function(T f) {
|
||||||
if (func_is_null(f)) {
|
if (func_is_null(f)) {
|
||||||
init_empty();
|
init_empty();
|
||||||
|
@ -801,7 +795,7 @@ struct Function<R(Args...)>: detail::FunctionBase<R, Args...> {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename A, typename T, typename = EnableIf<
|
template<typename A, typename T, typename = EnableIf<
|
||||||
detail::IsValidFunctor<T, R(Args...)>::value
|
detail::IsValidFunctor<T, R(Args...)>
|
||||||
>> Function(AllocatorArg, const A &a, T f) {
|
>> Function(AllocatorArg, const A &a, T f) {
|
||||||
if (func_is_null(f)) {
|
if (func_is_null(f)) {
|
||||||
init_empty();
|
init_empty();
|
||||||
|
@ -905,16 +899,15 @@ namespace detail {
|
||||||
using Obj = Function<R(A...)>;
|
using Obj = Function<R(A...)>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
struct DcFuncTest {
|
|
||||||
template<typename FF>
|
template<typename FF>
|
||||||
static char test(typename DcLambdaTypes<FF>::Ptr);
|
static char dc_func_test(typename DcLambdaTypes<FF>::Ptr);
|
||||||
template<typename FF>
|
template<typename FF>
|
||||||
static int test(...);
|
static int dc_func_test(...);
|
||||||
static constexpr bool value = (sizeof(test<F>(declval<F>())) == 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F, bool = DcFuncTest<F>::value>
|
template<typename F>
|
||||||
|
constexpr bool DcFuncTest = (sizeof(dc_func_test<F>(declval<F>())) == 1);
|
||||||
|
|
||||||
|
template<typename F, bool = DcFuncTest<F>>
|
||||||
struct DcFuncTypeObjBase {
|
struct DcFuncTypeObjBase {
|
||||||
using Type = typename DcLambdaTypes<F>::Obj;
|
using Type = typename DcLambdaTypes<F>::Obj;
|
||||||
};
|
};
|
||||||
|
|
|
@ -130,17 +130,12 @@ namespace detail {
|
||||||
static constexpr Size CHUNK_LOWER_BOUND = 32;
|
static constexpr Size CHUNK_LOWER_BOUND = 32;
|
||||||
static constexpr Size CHUNK_UPPER_BOUND = 128;
|
static constexpr Size CHUNK_UPPER_BOUND = 128;
|
||||||
|
|
||||||
template<typename E, Size N>
|
template<typename E, Size N> constexpr Size HashChainAlign
|
||||||
struct HashChainAlign {
|
= (((sizeof(HashChain<E>[N]) + sizeof(void *)) % CACHE_LINE_SIZE) == 0)
|
||||||
static constexpr Size csize = sizeof(HashChain<E>[N]) + sizeof(void *);
|
? N : HashChainAlign<E, N + 1>;
|
||||||
static constexpr Size value = ((csize % CACHE_LINE_SIZE) == 0)
|
|
||||||
? N : HashChainAlign<E, N + 1>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename E>
|
template<typename E>
|
||||||
struct HashChainAlign<E, CHUNK_UPPER_BOUND> {
|
constexpr Size HashChainAlign<E, CHUNK_UPPER_BOUND> = CHUNK_UPPER_BOUND;
|
||||||
static constexpr Size value = CHUNK_UPPER_BOUND;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<Size N, bool B>
|
template<Size N, bool B>
|
||||||
struct HashChainPad;
|
struct HashChainPad;
|
||||||
|
@ -156,7 +151,7 @@ namespace detail {
|
||||||
template<Size N>
|
template<Size N>
|
||||||
struct HashPad: HashChainPad<N, N % CACHE_LINE_SIZE == 0> {};
|
struct HashPad: HashChainPad<N, N % CACHE_LINE_SIZE == 0> {};
|
||||||
|
|
||||||
template<typename E, Size V = HashChainAlign<E, CHUNK_LOWER_BOUND>::value,
|
template<typename E, Size V = HashChainAlign<E, CHUNK_LOWER_BOUND>,
|
||||||
bool P = (V == CHUNK_UPPER_BOUND)
|
bool P = (V == CHUNK_UPPER_BOUND)
|
||||||
> struct HashChunk;
|
> struct HashChunk;
|
||||||
|
|
||||||
|
|
|
@ -53,19 +53,17 @@ OSTD_RANGE_TRAIT(Difference)
|
||||||
#undef OSTD_RANGE_TRAIT
|
#undef OSTD_RANGE_TRAIT
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename U> static char is_range_test(typename U::Category *,
|
||||||
struct IsRangeTest {
|
|
||||||
template<typename U> static char test(typename U::Category *,
|
|
||||||
typename U::Size *,
|
typename U::Size *,
|
||||||
typename U::Difference *,
|
typename U::Difference *,
|
||||||
typename U::Value *,
|
typename U::Value *,
|
||||||
RemoveReference<
|
RemoveReference<
|
||||||
typename U::Reference
|
typename U::Reference
|
||||||
> *);
|
> *);
|
||||||
template<typename U> static int test(...);
|
template<typename U> static int is_range_test(...);
|
||||||
static constexpr bool value
|
|
||||||
= (sizeof(test<T>(0, 0, 0, 0, 0)) == sizeof(char));
|
template<typename T> constexpr bool IsRangeTest
|
||||||
};
|
= (sizeof(is_range_test<T>(0, 0, 0, 0, 0)) == sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
// is input range
|
// is input range
|
||||||
|
@ -74,7 +72,7 @@ namespace detail {
|
||||||
template<typename T> constexpr bool IsInputRangeCore
|
template<typename T> constexpr bool IsInputRangeCore
|
||||||
= IsConvertible<RangeCategory<T>, InputRangeTag>;
|
= IsConvertible<RangeCategory<T>, InputRangeTag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsInputRangeBase = false;
|
constexpr bool IsInputRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -90,7 +88,7 @@ namespace detail {
|
||||||
template<typename T> constexpr bool IsForwardRangeCore
|
template<typename T> constexpr bool IsForwardRangeCore
|
||||||
= IsConvertible<RangeCategory<T>, ForwardRangeTag>;
|
= IsConvertible<RangeCategory<T>, ForwardRangeTag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsForwardRangeBase = false;
|
constexpr bool IsForwardRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -106,7 +104,7 @@ namespace detail {
|
||||||
template<typename T> constexpr bool IsBidirectionalRangeCore
|
template<typename T> constexpr bool IsBidirectionalRangeCore
|
||||||
= IsConvertible<RangeCategory<T>, BidirectionalRangeTag>;
|
= IsConvertible<RangeCategory<T>, BidirectionalRangeTag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsBidirectionalRangeBase = false;
|
constexpr bool IsBidirectionalRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -123,7 +121,7 @@ namespace detail {
|
||||||
template<typename T> constexpr bool IsRandomAccessRangeCore
|
template<typename T> constexpr bool IsRandomAccessRangeCore
|
||||||
= IsConvertible<RangeCategory<T>, RandomAccessRangeTag>;
|
= IsConvertible<RangeCategory<T>, RandomAccessRangeTag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsRandomAccessRangeBase = false;
|
constexpr bool IsRandomAccessRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -140,7 +138,7 @@ namespace detail {
|
||||||
template<typename T> constexpr bool IsFiniteRandomAccessRangeCore
|
template<typename T> constexpr bool IsFiniteRandomAccessRangeCore
|
||||||
= IsConvertible<RangeCategory<T>, FiniteRandomAccessRangeTag>;
|
= IsConvertible<RangeCategory<T>, FiniteRandomAccessRangeTag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsFiniteRandomAccessRangeBase = false;
|
constexpr bool IsFiniteRandomAccessRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -162,7 +160,7 @@ namespace detail {
|
||||||
template<typename T> constexpr bool IsContiguousRangeCore
|
template<typename T> constexpr bool IsContiguousRangeCore
|
||||||
= IsConvertible<RangeCategory<T>, ContiguousRangeTag>;
|
= IsConvertible<RangeCategory<T>, ContiguousRangeTag>;
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsContiguousRangeBase = false;
|
constexpr bool IsContiguousRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -191,7 +189,7 @@ namespace detail {
|
||||||
detail::OutputRangeTest<T, RangeValue<T> &&>::value ||
|
detail::OutputRangeTest<T, RangeValue<T> &&>::value ||
|
||||||
detail::OutputRangeTest<T, RangeValue<T> >::value));
|
detail::OutputRangeTest<T, RangeValue<T> >::value));
|
||||||
|
|
||||||
template<typename T, bool = detail::IsRangeTest<T>::value>
|
template<typename T, bool = detail::IsRangeTest<T>>
|
||||||
constexpr bool IsOutputRangeBase = false;
|
constexpr bool IsOutputRangeBase = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -262,29 +262,29 @@ namespace detail {
|
||||||
template<typename T, typename U,
|
template<typename T, typename U,
|
||||||
bool = IsSame<RemoveCv<T>, RemoveCv<U>>,
|
bool = IsSame<RemoveCv<T>, RemoveCv<U>>,
|
||||||
bool = IsEmpty<T>, bool = IsEmpty<U>
|
bool = IsEmpty<T>, bool = IsEmpty<U>
|
||||||
> struct CompressedPairSwitch;
|
> constexpr Size CompressedPairSwitch = detail::Undefined<T>();
|
||||||
|
|
||||||
/* neither empty */
|
/* neither empty */
|
||||||
template<typename T, typename U, bool Same>
|
template<typename T, typename U, bool Same>
|
||||||
struct CompressedPairSwitch<T, U, Same, false, false> { enum { value = 0 }; };
|
constexpr Size CompressedPairSwitch<T, U, Same, false, false> = 0;
|
||||||
|
|
||||||
/* first empty */
|
/* first empty */
|
||||||
template<typename T, typename U, bool Same>
|
template<typename T, typename U, bool Same>
|
||||||
struct CompressedPairSwitch<T, U, Same, true, false> { enum { value = 1 }; };
|
constexpr Size CompressedPairSwitch<T, U, Same, true, false> = 1;
|
||||||
|
|
||||||
/* second empty */
|
/* second empty */
|
||||||
template<typename T, typename U, bool Same>
|
template<typename T, typename U, bool Same>
|
||||||
struct CompressedPairSwitch<T, U, Same, false, true> { enum { value = 2 }; };
|
constexpr Size CompressedPairSwitch<T, U, Same, false, true> = 2;
|
||||||
|
|
||||||
/* both empty, not the same */
|
/* both empty, not the same */
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct CompressedPairSwitch<T, U, false, true, true> { enum { value = 3 }; };
|
constexpr Size CompressedPairSwitch<T, U, false, true, true> = 3;
|
||||||
|
|
||||||
/* both empty and same */
|
/* both empty and same */
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct CompressedPairSwitch<T, U, true, true, true> { enum { value = 1 }; };
|
constexpr Size CompressedPairSwitch<T, U, true, true, true> = 1;
|
||||||
|
|
||||||
template<typename T, typename U, Size = CompressedPairSwitch<T, U>::value>
|
template<typename T, typename U, Size = CompressedPairSwitch<T, U>>
|
||||||
struct CompressedPairBase;
|
struct CompressedPairBase;
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
|
|
Loading…
Reference in a new issue