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