replace usages of typedef with "using"
This commit is contained in:
parent
7f1c80e2d6
commit
6eae6487c4
18
octa/array.h
18
octa/array.h
|
@ -16,15 +16,15 @@ namespace octa {
|
||||||
|
|
||||||
template<typename T, size_t N>
|
template<typename T, size_t N>
|
||||||
struct Array {
|
struct Array {
|
||||||
typedef size_t Size;
|
using Size = size_t;
|
||||||
typedef ptrdiff_t Difference;
|
using Difference = ptrdiff_t;
|
||||||
typedef T Value;
|
using Value = T;
|
||||||
typedef T &Reference;
|
using Reference = T &;
|
||||||
typedef const T &ConstReference;
|
using ConstReference = const T &;
|
||||||
typedef T *Pointer;
|
using Pointer = T *;
|
||||||
typedef const T *ConstPointer;
|
using ConstPointer = const T *;
|
||||||
typedef PointerRange< T> Range;
|
using Range = PointerRange<T>;
|
||||||
typedef PointerRange<const T> ConstRange;
|
using ConstRange = PointerRange<const T>;
|
||||||
|
|
||||||
T &operator[](size_t i) { return p_buf[i]; }
|
T &operator[](size_t i) { return p_buf[i]; }
|
||||||
const T &operator[](size_t i) const { return p_buf[i]; }
|
const T &operator[](size_t i) const { return p_buf[i]; }
|
||||||
|
|
|
@ -382,11 +382,11 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Atomic<T, true>: Atomic<T, false> {
|
struct Atomic<T, true>: Atomic<T, false> {
|
||||||
typedef Atomic<T, false> _base_t;
|
using Base = Atomic<T, false>;
|
||||||
|
|
||||||
Atomic() = default;
|
Atomic() = default;
|
||||||
|
|
||||||
constexpr Atomic(T v): _base_t(v) {}
|
constexpr Atomic(T v): Base(v) {}
|
||||||
|
|
||||||
T fetch_add(T op, MemoryOrder ord = MemoryOrder::seq_cst) volatile {
|
T fetch_add(T op, MemoryOrder ord = MemoryOrder::seq_cst) volatile {
|
||||||
return atomic_fetch_add(&this->p_a, op, ord);
|
return atomic_fetch_add(&this->p_a, op, ord);
|
||||||
|
@ -452,35 +452,35 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Atomic: octa::detail::Atomic<T> {
|
struct Atomic: octa::detail::Atomic<T> {
|
||||||
typedef octa::detail::Atomic<T> _base_t;
|
using Base = octa::detail::Atomic<T>;
|
||||||
|
|
||||||
Atomic() = default;
|
Atomic() = default;
|
||||||
|
|
||||||
constexpr Atomic(T v): _base_t(v) {}
|
constexpr Atomic(T v): Base(v) {}
|
||||||
|
|
||||||
T operator=(T v) volatile {
|
T operator=(T v) volatile {
|
||||||
_base_t::store(v); return v;
|
Base::store(v); return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
T operator=(T v) {
|
T operator=(T v) {
|
||||||
_base_t::store(v); return v;
|
Base::store(v); return v;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Atomic<T *>: octa::detail::Atomic<T *> {
|
struct Atomic<T *>: octa::detail::Atomic<T *> {
|
||||||
typedef octa::detail::Atomic<T *> _base_t;
|
using Base = octa::detail::Atomic<T *>;
|
||||||
|
|
||||||
Atomic() = default;
|
Atomic() = default;
|
||||||
|
|
||||||
constexpr Atomic(T *v): _base_t(v) {}
|
constexpr Atomic(T *v): Base(v) {}
|
||||||
|
|
||||||
T *operator=(T *v) volatile {
|
T *operator=(T *v) volatile {
|
||||||
_base_t::store(v); return v;
|
Base::store(v); return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator=(T *v) {
|
T *operator=(T *v) {
|
||||||
_base_t::store(v); return v;
|
Base::store(v); return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *fetch_add(ptrdiff_t op, MemoryOrder ord = MemoryOrder::seq_cst)
|
T *fetch_add(ptrdiff_t op, MemoryOrder ord = MemoryOrder::seq_cst)
|
||||||
|
@ -917,27 +917,27 @@ namespace detail {
|
||||||
octa::detail::atomic_signal_fence(ord);
|
octa::detail::atomic_signal_fence(ord);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Atomic<bool > AtomicBool;
|
using AtomicBool = Atomic<bool>;
|
||||||
typedef Atomic<char > AtomicChar;
|
using AtomicChar = Atomic<char>;
|
||||||
typedef Atomic<schar > AtomicSchar;
|
using AtomicSchar = Atomic<schar>;
|
||||||
typedef Atomic<uchar > AtomicUchar;
|
using AtomicUchar = Atomic<uchar>;
|
||||||
typedef Atomic<short > AtomicShort;
|
using AtomicShort = Atomic<short>;
|
||||||
typedef Atomic<ushort> AtomicUshort;
|
using AtomicUshort = Atomic<ushort>;
|
||||||
typedef Atomic<int > AtomicInt;
|
using AtomicInt = Atomic<int>;
|
||||||
typedef Atomic<uint > AtomicUint;
|
using AtomicUint = Atomic<uint>;
|
||||||
typedef Atomic<long > AtomicLong;
|
using AtomicLong = Atomic<long>;
|
||||||
typedef Atomic<ulong > AtomicUlong;
|
using AtomicUlong = Atomic<ulong>;
|
||||||
typedef Atomic<llong > AtomicLlong;
|
using AtomicLlong = Atomic<llong>;
|
||||||
typedef Atomic<ullong> AtomicUllong;
|
using AtomicUllong = Atomic<ullong>;
|
||||||
|
|
||||||
typedef Atomic<char16_t> AtomicChar16;
|
using AtomicChar16 = Atomic<char16_t>;
|
||||||
typedef Atomic<char32_t> AtomicChar32;
|
using AtomicChar32 = Atomic<char32_t>;
|
||||||
typedef Atomic< wchar_t> AtomicWchar;
|
using AtomicWchar = Atomic<wchar_t>;
|
||||||
|
|
||||||
typedef Atomic< intptr_t> AtomicIntptr;
|
using AtomicIntptr = Atomic<intptr_t>;
|
||||||
typedef Atomic<uintptr_t> AtomicUintptr;
|
using AtomicUintptr = Atomic<uintptr_t>;
|
||||||
typedef Atomic< size_t> AtomicSize;
|
using AtomicSize = Atomic<size_t>;
|
||||||
typedef Atomic<ptrdiff_t> AtomicPtrdiff;
|
using AtomicPtrdiff = Atomic<ptrdiff_t>;
|
||||||
|
|
||||||
#define ATOMIC_FLAG_INIT {false}
|
#define ATOMIC_FLAG_INIT {false}
|
||||||
#define ATOMIC_VAR_INIT(v) {v}
|
#define ATOMIC_VAR_INIT(v) {v}
|
||||||
|
|
|
@ -15,14 +15,14 @@ namespace octa {
|
||||||
|
|
||||||
/* basic function objects */
|
/* basic function objects */
|
||||||
|
|
||||||
#define OCTA_DEFINE_BINARY_OP(_name, _op, _rettype) \
|
#define OCTA_DEFINE_BINARY_OP(name, op, RT) \
|
||||||
template<typename T> struct _name { \
|
template<typename T> struct name { \
|
||||||
_rettype operator()(const T &x, const T &y) const { \
|
RT operator()(const T &x, const T &y) const { \
|
||||||
return x _op y; \
|
return x op y; \
|
||||||
} \
|
} \
|
||||||
typedef T FirstArgument; \
|
using FirstArgument = T; \
|
||||||
typedef T SecondArgument; \
|
using SecondARgument = T; \
|
||||||
typedef _rettype Result; \
|
using Result = RT; \
|
||||||
};
|
};
|
||||||
|
|
||||||
OCTA_DEFINE_BINARY_OP(Less, <, bool)
|
OCTA_DEFINE_BINARY_OP(Less, <, bool)
|
||||||
|
@ -46,20 +46,20 @@ OCTA_DEFINE_BINARY_OP(BitXor, ^, T)
|
||||||
|
|
||||||
template<typename T> struct LogicalNot {
|
template<typename T> struct LogicalNot {
|
||||||
bool operator()(const T &x) const { return !x; }
|
bool operator()(const T &x) const { return !x; }
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef bool Result;
|
using Result = bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct Negate {
|
template<typename T> struct Negate {
|
||||||
bool operator()(const T &x) const { return -x; }
|
bool operator()(const T &x) const { return -x; }
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef T Result;
|
using Result = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct BinaryNegate {
|
template<typename T> struct BinaryNegate {
|
||||||
typedef typename T::FirstArgument FirstArgument;
|
using FirstArgument = typename T::FirstArgument;
|
||||||
typedef typename T::SecondArgument SecondArgument;
|
using SecondArgument = typename T::SecondArgument;
|
||||||
typedef bool Result;
|
using Result = bool;
|
||||||
|
|
||||||
explicit BinaryNegate(const T &f): p_fn(f) {}
|
explicit BinaryNegate(const T &f): p_fn(f) {}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct UnaryNegate {
|
template<typename T> struct UnaryNegate {
|
||||||
typedef typename T::Argument Argument;
|
using Argument = typename T::Argument;
|
||||||
typedef bool Result;
|
using Result = bool;
|
||||||
|
|
||||||
explicit UnaryNegate(const T &f): p_fn(f) {}
|
explicit UnaryNegate(const T &f): p_fn(f) {}
|
||||||
bool operator()(const Argument &x) {
|
bool operator()(const Argument &x) {
|
||||||
|
@ -97,8 +97,8 @@ template<typename T> struct Hash;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T> struct HashBase {
|
template<typename T> struct HashBase {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T v) const {
|
size_t operator()(T v) const {
|
||||||
return size_t(v);
|
return size_t(v);
|
||||||
|
@ -136,8 +136,8 @@ namespace detail {
|
||||||
struct ScalarHash;
|
struct ScalarHash;
|
||||||
|
|
||||||
template<typename T> struct ScalarHash<T, 0> {
|
template<typename T> struct ScalarHash<T, 0> {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T v) const {
|
size_t operator()(T v) const {
|
||||||
union { T v; size_t h; } u;
|
union { T v; size_t h; } u;
|
||||||
|
@ -148,8 +148,8 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct ScalarHash<T, 1> {
|
template<typename T> struct ScalarHash<T, 1> {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T v) const {
|
size_t operator()(T v) const {
|
||||||
union { T v; size_t h; } u;
|
union { T v; size_t h; } u;
|
||||||
|
@ -159,8 +159,8 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct ScalarHash<T, 2> {
|
template<typename T> struct ScalarHash<T, 2> {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T v) const {
|
size_t operator()(T v) const {
|
||||||
union { T v; struct { size_t h1, h2; }; } u;
|
union { T v; struct { size_t h1, h2; }; } u;
|
||||||
|
@ -170,8 +170,8 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct ScalarHash<T, 3> {
|
template<typename T> struct ScalarHash<T, 3> {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T v) const {
|
size_t operator()(T v) const {
|
||||||
union { T v; struct { size_t h1, h2, h3; }; } u;
|
union { T v; struct { size_t h1, h2, h3; }; } u;
|
||||||
|
@ -181,8 +181,8 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct ScalarHash<T, 4> {
|
template<typename T> struct ScalarHash<T, 4> {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T v) const {
|
size_t operator()(T v) const {
|
||||||
union { T v; struct { size_t h1, h2, h3, h4; }; } u;
|
union { T v; struct { size_t h1, h2, h3, h4; }; } u;
|
||||||
|
@ -231,8 +231,8 @@ template<> struct Hash<ldouble>: octa::detail::ScalarHash<ldouble> {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct Hash<T *> {
|
template<typename T> struct Hash<T *> {
|
||||||
typedef T *Argument;
|
using Argument = T *;
|
||||||
typedef size_t Result;
|
using Result = size_t;
|
||||||
|
|
||||||
size_t operator()(T *v) const {
|
size_t operator()(T *v) const {
|
||||||
union { T *v; size_t h; } u;
|
union { T *v; size_t h; } u;
|
||||||
|
@ -245,7 +245,7 @@ template<typename T> struct Hash<T *> {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct ReferenceWrapper {
|
struct ReferenceWrapper {
|
||||||
typedef T type;
|
using Type = T;
|
||||||
|
|
||||||
ReferenceWrapper(T &v): p_ptr(address_of(v)) {}
|
ReferenceWrapper(T &v): p_ptr(address_of(v)) {}
|
||||||
ReferenceWrapper(const ReferenceWrapper &) = default;
|
ReferenceWrapper(const ReferenceWrapper &) = default;
|
||||||
|
@ -286,25 +286,25 @@ namespace detail {
|
||||||
template<typename, typename> struct MemTypes;
|
template<typename, typename> struct MemTypes;
|
||||||
template<typename T, typename R, typename ...A>
|
template<typename T, typename R, typename ...A>
|
||||||
struct MemTypes<T, R(A...)> {
|
struct MemTypes<T, R(A...)> {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
};
|
};
|
||||||
template<typename T, typename R, typename A>
|
template<typename T, typename R, typename A>
|
||||||
struct MemTypes<T, R(A)> {
|
struct MemTypes<T, R(A)> {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
typedef T FirstArgument;
|
using FirstArgument = T;
|
||||||
typedef A SecondArgument;
|
using SecondArgument = A;
|
||||||
};
|
};
|
||||||
template<typename T, typename R, typename ...A>
|
template<typename T, typename R, typename ...A>
|
||||||
struct MemTypes<T, R(A...) const> {
|
struct MemTypes<T, R(A...) const> {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
typedef const T Argument;
|
using Argument = const T;
|
||||||
};
|
};
|
||||||
template<typename T, typename R, typename A>
|
template<typename T, typename R, typename A>
|
||||||
struct MemTypes<T, R(A) const> {
|
struct MemTypes<T, R(A) const> {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
typedef const T FirstArgument;
|
using FirstArgument = const T;
|
||||||
typedef A SecondArgument;
|
using SecondArgument = A;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
|
@ -488,9 +488,9 @@ namespace detail {
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
static void call_move_and_destroy(FmStorage &lhs,
|
static void call_move_and_destroy(FmStorage &lhs,
|
||||||
FmStorage &&rhs) {
|
FmStorage &&rhs) {
|
||||||
typedef FunctorDataManager<T, A> _spec;
|
using Spec = FunctorDataManager<T, A>;
|
||||||
_spec::move_f(lhs, octa::move(rhs));
|
Spec::move_f(lhs, octa::move(rhs));
|
||||||
_spec::destroy_f(rhs.get_alloc<A>(), rhs);
|
Spec::destroy_f(rhs.get_alloc<A>(), rhs);
|
||||||
create_fm<T, A>(lhs, octa::move(rhs.get_alloc<A>()));
|
create_fm<T, A>(lhs, octa::move(rhs.get_alloc<A>()));
|
||||||
rhs.get_alloc<A>().~A();
|
rhs.get_alloc<A>().~A();
|
||||||
}
|
}
|
||||||
|
@ -498,22 +498,22 @@ namespace detail {
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
static void call_copy(FmStorage &lhs,
|
static void call_copy(FmStorage &lhs,
|
||||||
const FmStorage &rhs) {
|
const FmStorage &rhs) {
|
||||||
typedef FunctorDataManager<T, A> _spec;
|
using Spec = FunctorDataManager<T, A>;
|
||||||
create_fm<T, A>(lhs, A(rhs.get_alloc<A>()));
|
create_fm<T, A>(lhs, A(rhs.get_alloc<A>()));
|
||||||
_spec::store_f(lhs, _spec::get_ref(rhs));
|
Spec::store_f(lhs, Spec::get_ref(rhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
static void call_copy_fo(FmStorage &lhs,
|
static void call_copy_fo(FmStorage &lhs,
|
||||||
const FmStorage &rhs) {
|
const FmStorage &rhs) {
|
||||||
typedef FunctorDataManager<T, A> _spec;
|
using Spec = FunctorDataManager<T, A>;
|
||||||
_spec::store_f(lhs, _spec::get_ref(rhs));
|
Spec::store_f(lhs, Spec::get_ref(rhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
static void call_destroy(FmStorage &s) {
|
static void call_destroy(FmStorage &s) {
|
||||||
typedef FunctorDataManager<T, A> _spec;
|
using Spec = FunctorDataManager<T, A>;
|
||||||
_spec::destroy_f(s.get_alloc<A>(), s);
|
Spec::destroy_f(s.get_alloc<A>(), s);
|
||||||
s.get_alloc<A>().~A();
|
s.get_alloc<A>().~A();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -527,20 +527,20 @@ namespace detail {
|
||||||
|
|
||||||
template<typename R, typename...>
|
template<typename R, typename...>
|
||||||
struct FunctionBase {
|
struct FunctionBase {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
struct FunctionBase<R, T> {
|
struct FunctionBase<R, T> {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename T, typename U>
|
template<typename R, typename T, typename U>
|
||||||
struct FunctionBase<R, T, U> {
|
struct FunctionBase<R, T, U> {
|
||||||
typedef R Result;
|
using Result = R;
|
||||||
typedef T FirstArgument;
|
using FirstArgument = T;
|
||||||
typedef U SecondArgument;
|
using SecondArgument = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename, typename>
|
template<typename, typename>
|
||||||
|
@ -638,7 +638,7 @@ struct Function<R(Args...)>: octa::detail::FunctionBase<R, Args...> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef AllocatorRebind<A, Function> AA;
|
using AA = AllocatorRebind<A, Function>;
|
||||||
const octa::detail::FunctionManager *mff
|
const octa::detail::FunctionManager *mff
|
||||||
= &octa::detail::get_default_fm<Function, AA>();
|
= &octa::detail::get_default_fm<Function, AA>();
|
||||||
if (f.p_stor.manager == mff) {
|
if (f.p_stor.manager == mff) {
|
||||||
|
@ -712,8 +712,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_empty() {
|
void init_empty() {
|
||||||
typedef R(*emptyf)(Args...);
|
using emptyf = R(*)(Args...);
|
||||||
typedef octa::Allocator<emptyf> emptya;
|
using emptya = octa::Allocator<emptyf>;
|
||||||
p_call = nullptr;
|
p_call = nullptr;
|
||||||
octa::detail::create_fm<emptyf, emptya>(p_stor, emptya());
|
octa::detail::create_fm<emptyf, emptya>(p_stor, emptya());
|
||||||
octa::detail::FunctorDataManager<emptyf, emptya>::store_f(p_stor,
|
octa::detail::FunctorDataManager<emptyf, emptya>::store_f(p_stor,
|
||||||
|
@ -756,8 +756,8 @@ namespace detail {
|
||||||
|
|
||||||
template<typename C, typename R, typename ...A>
|
template<typename C, typename R, typename ...A>
|
||||||
struct DcLambdaTypes<R (C::*)(A...) const> {
|
struct DcLambdaTypes<R (C::*)(A...) const> {
|
||||||
typedef R (*Ptr)(A...);
|
using Ptr = R (*)(A...);
|
||||||
typedef octa::Function<R(A...)> Obj;
|
using Obj = octa::Function<R(A...)>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
|
@ -771,33 +771,33 @@ namespace detail {
|
||||||
|
|
||||||
template<typename F, bool = DcFuncTest<F>::value>
|
template<typename F, bool = DcFuncTest<F>::value>
|
||||||
struct DcFuncTypeObjBase {
|
struct DcFuncTypeObjBase {
|
||||||
typedef typename DcLambdaTypes<F>::Obj Type;
|
using Type = typename DcLambdaTypes<F>::Obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
struct DcFuncTypeObjBase<F, true> {
|
struct DcFuncTypeObjBase<F, true> {
|
||||||
typedef typename DcLambdaTypes<F>::Ptr Type;
|
using Type = typename DcLambdaTypes<F>::Ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F, bool = octa::IsDefaultConstructible<F>::value &&
|
template<typename F, bool = octa::IsDefaultConstructible<F>::value &&
|
||||||
octa::IsMoveConstructible<F>::value
|
octa::IsMoveConstructible<F>::value
|
||||||
> struct DcFuncTypeObj {
|
> struct DcFuncTypeObj {
|
||||||
typedef typename DcFuncTypeObjBase<F>::Type Type;
|
using Type = typename DcFuncTypeObjBase<F>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
struct DcFuncTypeObj<F, true> {
|
struct DcFuncTypeObj<F, true> {
|
||||||
typedef F Type;
|
using Type = F;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F, bool = octa::IsClass<F>::value>
|
template<typename F, bool = octa::IsClass<F>::value>
|
||||||
struct DcFuncType {
|
struct DcFuncType {
|
||||||
typedef F Type;
|
using Type = F;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
struct DcFuncType<F, true> {
|
struct DcFuncType<F, true> {
|
||||||
typedef typename DcFuncTypeObj<F>::Type Type;
|
using Type = typename DcFuncTypeObj<F>::Type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
150
octa/memory.h
150
octa/memory.h
|
@ -35,27 +35,27 @@ namespace detail {
|
||||||
struct PointerElementBase;
|
struct PointerElementBase;
|
||||||
|
|
||||||
template<typename T> struct PointerElementBase<T, true> {
|
template<typename T> struct PointerElementBase<T, true> {
|
||||||
typedef typename T::Element Type;
|
using Type = typename T::Element;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename, typename...> class T, typename U, typename ...A>
|
template<template<typename, typename...> class T, typename U, typename ...A>
|
||||||
struct PointerElementBase<T<U, A...>, true> {
|
struct PointerElementBase<T<U, A...>, true> {
|
||||||
typedef typename T<U, A...>::Element Type;
|
using Type = typename T<U, A...>::Element;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename, typename...> class T, typename U, typename ...A>
|
template<template<typename, typename...> class T, typename U, typename ...A>
|
||||||
struct PointerElementBase<T<U, A...>, false> {
|
struct PointerElementBase<T<U, A...>, false> {
|
||||||
typedef U Type;
|
using Type = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerElementType {
|
struct PointerElementType {
|
||||||
typedef typename PointerElementBase<T>::Type Type;
|
using Type = typename PointerElementBase<T>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerElementType<T *> {
|
struct PointerElementType<T *> {
|
||||||
typedef T Type;
|
using Type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -68,21 +68,21 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, bool = HasDifference<T>::value>
|
template<typename T, bool = HasDifference<T>::value>
|
||||||
struct PointerDifferenceBase {
|
struct PointerDifferenceBase {
|
||||||
typedef ptrdiff_t Type;
|
using Type = ptrdiff_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct PointerDifferenceBase<T, true> {
|
template<typename T> struct PointerDifferenceBase<T, true> {
|
||||||
typedef typename T::Difference Type;
|
using Type = typename T::Difference;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerDifferenceType {
|
struct PointerDifferenceType {
|
||||||
typedef typename PointerDifferenceBase<T>::Type Type;
|
using Type = typename PointerDifferenceBase<T>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerDifferenceType<T *> {
|
struct PointerDifferenceType<T *> {
|
||||||
typedef ptrdiff_t Type;
|
using Type = ptrdiff_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
|
@ -96,21 +96,21 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, typename U, bool = HasRebind<T, U>::value>
|
template<typename T, typename U, bool = HasRebind<T, U>::value>
|
||||||
struct PointerRebindBase {
|
struct PointerRebindBase {
|
||||||
typedef typename T::template Rebind<U> Type;
|
using Type = typename T::template Rebind<U>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename, typename...> class T, typename U,
|
template<template<typename, typename...> class T, typename U,
|
||||||
typename ...A, typename V
|
typename ...A, typename V
|
||||||
>
|
>
|
||||||
struct PointerRebindBase<T<U, A...>, V, true> {
|
struct PointerRebindBase<T<U, A...>, V, true> {
|
||||||
typedef typename T<U, A...>::template Rebind<V> Type;
|
using Type = typename T<U, A...>::template Rebind<V>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename, typename...> class T, typename U,
|
template<template<typename, typename...> class T, typename U,
|
||||||
typename ...A, typename V
|
typename ...A, typename V
|
||||||
>
|
>
|
||||||
struct PointerRebindBase<T<U, A...>, V, false> {
|
struct PointerRebindBase<T<U, A...>, V, false> {
|
||||||
typedef T<V, A...> Type;
|
using Type = T<V, A...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
|
@ -125,12 +125,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerPointer {
|
struct PointerPointer {
|
||||||
typedef T Type;
|
using Type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerPointer<T *> {
|
struct PointerPointer<T *> {
|
||||||
typedef T *Type;
|
using Type = T *;
|
||||||
};
|
};
|
||||||
} /*namespace detail */
|
} /*namespace detail */
|
||||||
|
|
||||||
|
@ -255,29 +255,29 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, typename D, bool = HasPtr<D>::value>
|
template<typename T, typename D, bool = HasPtr<D>::value>
|
||||||
struct PointerBase {
|
struct PointerBase {
|
||||||
typedef typename D::Pointer Type;
|
using Type = typename D::Pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename D> struct PointerBase<T, D, false> {
|
template<typename T, typename D> struct PointerBase<T, D, false> {
|
||||||
typedef T *Type;
|
using Type = T *;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename D> struct PointerType {
|
template<typename T, typename D> struct PointerType {
|
||||||
typedef typename PointerBase<T, octa::RemoveReference<D>>::Type Type;
|
using Type = typename PointerBase<T, octa::RemoveReference<D>>::Type;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
template<typename T, typename D = DefaultDelete<T>>
|
template<typename T, typename D = DefaultDelete<T>>
|
||||||
struct Box {
|
struct Box {
|
||||||
typedef T Element;
|
using Element = T;
|
||||||
typedef D Deleter;
|
using Deleter = D;
|
||||||
typedef typename octa::detail::PointerType<T, D>::Type Pointer;
|
using Pointer = typename octa::detail::PointerType<T, D>::Type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Nat { int x; };
|
struct Nat { int x; };
|
||||||
|
|
||||||
typedef RemoveReference<D> &D_ref;
|
using Dref = RemoveReference<D> &;
|
||||||
typedef const RemoveReference<D> &D_cref;
|
using Dcref = const RemoveReference<D> &;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr Box(): p_stor(nullptr, D()) {
|
constexpr Box(): p_stor(nullptr, D()) {
|
||||||
|
@ -346,8 +346,8 @@ public:
|
||||||
|
|
||||||
Pointer get() const { return p_stor.p_ptr; }
|
Pointer get() const { return p_stor.p_ptr; }
|
||||||
|
|
||||||
D_ref get_deleter() { return p_stor.get_deleter(); }
|
Dref get_deleter() { return p_stor.get_deleter(); }
|
||||||
D_cref get_deleter() const { return p_stor.get_deleter(); }
|
Dcref get_deleter() const { return p_stor.get_deleter(); }
|
||||||
|
|
||||||
Pointer release() {
|
Pointer release() {
|
||||||
Pointer p = p_stor.p_ptr;
|
Pointer p = p_stor.p_ptr;
|
||||||
|
@ -388,15 +388,15 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, typename D>
|
template<typename T, typename D>
|
||||||
struct Box<T[], D> {
|
struct Box<T[], D> {
|
||||||
typedef T Element;
|
using Element = T;
|
||||||
typedef D Deleter;
|
using Deleter = D;
|
||||||
typedef typename octa::detail::PointerType<T, D>::Type Pointer;
|
using Pointer = typename octa::detail::PointerType<T, D>::Type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Nat { int x; };
|
struct Nat { int x; };
|
||||||
|
|
||||||
typedef RemoveReference<D> &D_ref;
|
using Dref = RemoveReference<D> &;
|
||||||
typedef const RemoveReference<D> &D_cref;
|
using Dcref = const RemoveReference<D> &;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr Box(): p_stor(nullptr, D()) {
|
constexpr Box(): p_stor(nullptr, D()) {
|
||||||
|
@ -485,8 +485,8 @@ public:
|
||||||
|
|
||||||
Pointer get() const { return p_stor.p_ptr; }
|
Pointer get() const { return p_stor.p_ptr; }
|
||||||
|
|
||||||
D_ref get_deleter() { return p_stor.get_deleter(); }
|
Dref get_deleter() { return p_stor.get_deleter(); }
|
||||||
D_cref get_deleter() const { return p_stor.get_deleter(); }
|
Dcref get_deleter() const { return p_stor.get_deleter(); }
|
||||||
|
|
||||||
Pointer release() {
|
Pointer release() {
|
||||||
Pointer p = p_stor.p_ptr;
|
Pointer p = p_stor.p_ptr;
|
||||||
|
@ -522,15 +522,15 @@ private:
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T> struct BoxIf {
|
template<typename T> struct BoxIf {
|
||||||
typedef octa::Box<T> Box;
|
using Box = octa::Box<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct BoxIf<T[]> {
|
template<typename T> struct BoxIf<T[]> {
|
||||||
typedef octa::Box<T[]> BoxUnknownSize;
|
using BoxUnknownSize = octa::Box<T[]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, size_t N> struct BoxIf<T[N]> {
|
template<typename T, size_t N> struct BoxIf<T[N]> {
|
||||||
typedef void BoxKnownSize;
|
using BoxKnownSize = void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,29 +552,29 @@ typename octa::detail::BoxIf<T>::BoxKnownSize make_box(A &&...args) = delete;
|
||||||
template<typename> struct Allocator;
|
template<typename> struct Allocator;
|
||||||
|
|
||||||
template<> struct Allocator<void> {
|
template<> struct Allocator<void> {
|
||||||
typedef void Value;
|
using Value = void;
|
||||||
typedef void *Pointer;
|
using Pointer = void *;
|
||||||
typedef const void *ConstPointer;
|
using ConstPointer = const void *;
|
||||||
|
|
||||||
template<typename U> using Rebind = Allocator<U>;
|
template<typename U> using Rebind = Allocator<U>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct Allocator<const void> {
|
template<> struct Allocator<const void> {
|
||||||
typedef const void Value;
|
using Value = const void;
|
||||||
typedef const void *Pointer;
|
using Pointer = const void *;
|
||||||
typedef const void *ConstPointer;
|
using ConstPointer = const void *;
|
||||||
|
|
||||||
template<typename U> using Rebind = Allocator<U>;
|
template<typename U> using Rebind = Allocator<U>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct Allocator {
|
template<typename T> struct Allocator {
|
||||||
typedef size_t Size;
|
using Size = size_t;
|
||||||
typedef ptrdiff_t Difference;
|
using Difference = ptrdiff_t;
|
||||||
typedef T Value;
|
using Value = T;
|
||||||
typedef T &Reference;
|
using Reference = T &;
|
||||||
typedef const T &ConstReference;
|
using ConstReference = const T &;
|
||||||
typedef T *Pointer;
|
using Pointer = T *;
|
||||||
typedef const T *ConstPointer;
|
using ConstPointer = const T *;
|
||||||
|
|
||||||
template<typename U> using Rebind = Allocator<U>;
|
template<typename U> using Rebind = Allocator<U>;
|
||||||
|
|
||||||
|
@ -602,13 +602,13 @@ template<typename T> struct Allocator {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct Allocator<const T> {
|
template<typename T> struct Allocator<const T> {
|
||||||
typedef size_t Size;
|
using Size = size_t;
|
||||||
typedef ptrdiff_t Difference;
|
using Difference = ptrdiff_t;
|
||||||
typedef const T Value;
|
using Value = const T;
|
||||||
typedef const T &Reference;
|
using Reference = const T &;
|
||||||
typedef const T &ConstReference;
|
using ConstReference = const T &;
|
||||||
typedef const T *Pointer;
|
using Pointer = const T *;
|
||||||
typedef const T *ConstPointer;
|
using ConstPointer = const T *;
|
||||||
|
|
||||||
template<typename U> using Rebind = Allocator<U>;
|
template<typename U> using Rebind = Allocator<U>;
|
||||||
|
|
||||||
|
@ -656,12 +656,12 @@ namespace detail {
|
||||||
template<typename T, typename P, typename A,
|
template<typename T, typename P, typename A,
|
||||||
bool = ConstPtrTest<A>::value>
|
bool = ConstPtrTest<A>::value>
|
||||||
struct ConstPointer {
|
struct ConstPointer {
|
||||||
typedef typename A::ConstPointer Type;
|
using Type = typename A::ConstPointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename P, typename A>
|
template<typename T, typename P, typename A>
|
||||||
struct ConstPointer<T, P, A, false> {
|
struct ConstPointer<T, P, A, false> {
|
||||||
typedef PointerRebind<P, const T> Type;
|
using Type = PointerRebind<P, const T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -674,12 +674,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename P, typename A, bool = VoidPtrTest<A>::value>
|
template<typename P, typename A, bool = VoidPtrTest<A>::value>
|
||||||
struct VoidPointer {
|
struct VoidPointer {
|
||||||
typedef typename A::VoidPointer Type;
|
using Type = typename A::VoidPointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename P, typename A>
|
template<typename P, typename A>
|
||||||
struct VoidPointer<P, A, false> {
|
struct VoidPointer<P, A, false> {
|
||||||
typedef PointerRebind<P, void> Type;
|
using Type = PointerRebind<P, void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -692,12 +692,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename P, typename A, bool = ConstVoidPtrTest<A>::value>
|
template<typename P, typename A, bool = ConstVoidPtrTest<A>::value>
|
||||||
struct ConstVoidPointer {
|
struct ConstVoidPointer {
|
||||||
typedef typename A::ConstVoidPointer Type;
|
using Type = typename A::ConstVoidPointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename P, typename A>
|
template<typename P, typename A>
|
||||||
struct ConstVoidPointer<P, A, false> {
|
struct ConstVoidPointer<P, A, false> {
|
||||||
typedef PointerRebind<P, const void> Type;
|
using Type = PointerRebind<P, const void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -709,12 +709,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename A, typename D, bool = SizeTest<A>::value>
|
template<typename A, typename D, bool = SizeTest<A>::value>
|
||||||
struct SizeBase {
|
struct SizeBase {
|
||||||
typedef octa::MakeUnsigned<D> Type;
|
using Type = octa::MakeUnsigned<D>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A, typename D>
|
template<typename A, typename D>
|
||||||
struct SizeBase<A, D, true> {
|
struct SizeBase<A, D, true> {
|
||||||
typedef typename A::Size Type;
|
using Type = typename A::Size;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -758,12 +758,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename A, typename P, bool = DiffTest<A>::value>
|
template<typename A, typename P, bool = DiffTest<A>::value>
|
||||||
struct AllocDifference {
|
struct AllocDifference {
|
||||||
typedef PointerDifference<P> Type;
|
using Type = PointerDifference<P>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A, typename P>
|
template<typename A, typename P>
|
||||||
struct AllocDifference<A, P, true> {
|
struct AllocDifference<A, P, true> {
|
||||||
typedef typename A::Difference Type;
|
using Type = typename A::Difference;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,21 +784,21 @@ using AllocatorSize = typename octa::detail::SizeBase<
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, typename U, bool = octa::detail::HasRebind<T, U>::value>
|
template<typename T, typename U, bool = octa::detail::HasRebind<T, U>::value>
|
||||||
struct AllocTraitsRebindType {
|
struct AllocTraitsRebindType {
|
||||||
typedef typename T::template Rebind<U> Type;
|
using Type = typename T::template Rebind<U>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename, typename...> class A, typename T,
|
template<template<typename, typename...> class A, typename T,
|
||||||
typename ...Args, typename U
|
typename ...Args, typename U
|
||||||
>
|
>
|
||||||
struct AllocTraitsRebindType<A<T, Args...>, U, true> {
|
struct AllocTraitsRebindType<A<T, Args...>, U, true> {
|
||||||
typedef typename A<T, Args...>::template Rebind<U> Type;
|
using Type = typename A<T, Args...>::template Rebind<U>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template<typename, typename...> class A, typename T,
|
template<template<typename, typename...> class A, typename T,
|
||||||
typename ...Args, typename U
|
typename ...Args, typename U
|
||||||
>
|
>
|
||||||
struct AllocTraitsRebindType<A<T, Args...>, U, false> {
|
struct AllocTraitsRebindType<A<T, Args...>, U, false> {
|
||||||
typedef A<U, Args...> Type;
|
using Type = A<U, Args...>;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -821,12 +821,12 @@ namespace detail {
|
||||||
template<typename A, bool = PropagateOnContainerCopyAssignmentTest<
|
template<typename A, bool = PropagateOnContainerCopyAssignmentTest<
|
||||||
A
|
A
|
||||||
>::value> struct PropagateOnContainerCopyAssignmentBase {
|
>::value> struct PropagateOnContainerCopyAssignmentBase {
|
||||||
typedef octa::False Type;
|
using Type = octa::False;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
struct PropagateOnContainerCopyAssignmentBase<A, true> {
|
struct PropagateOnContainerCopyAssignmentBase<A, true> {
|
||||||
typedef typename A::PropagateOnContainerCopyAssignment Type;
|
using Type = typename A::PropagateOnContainerCopyAssignment;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -848,12 +848,12 @@ namespace detail {
|
||||||
template<typename A, bool = PropagateOnContainerMoveAssignmentTest<
|
template<typename A, bool = PropagateOnContainerMoveAssignmentTest<
|
||||||
A
|
A
|
||||||
>::value> struct PropagateOnContainerMoveAssignmentBase {
|
>::value> struct PropagateOnContainerMoveAssignmentBase {
|
||||||
typedef octa::False Type;
|
using Type = octa::False;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
struct PropagateOnContainerMoveAssignmentBase<A, true> {
|
struct PropagateOnContainerMoveAssignmentBase<A, true> {
|
||||||
typedef typename A::PropagateOnContainerMoveAssignment Type;
|
using Type = typename A::PropagateOnContainerMoveAssignment;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -874,12 +874,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename A, bool = PropagateOnContainerSwapTest<A>::value>
|
template<typename A, bool = PropagateOnContainerSwapTest<A>::value>
|
||||||
struct PropagateOnContainerSwapBase {
|
struct PropagateOnContainerSwapBase {
|
||||||
typedef octa::False Type;
|
using Type = octa::False;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
struct PropagateOnContainerSwapBase<A, true> {
|
struct PropagateOnContainerSwapBase<A, true> {
|
||||||
typedef typename A::PropagateOnContainerSwap Type;
|
using Type = typename A::PropagateOnContainerSwap;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -899,12 +899,12 @@ namespace detail {
|
||||||
|
|
||||||
template<typename A, bool = IsAlwaysEqualTest<A>::value>
|
template<typename A, bool = IsAlwaysEqualTest<A>::value>
|
||||||
struct IsAlwaysEqualBase {
|
struct IsAlwaysEqualBase {
|
||||||
typedef typename octa::IsEmpty<A>::Type Type;
|
using Type = typename octa::IsEmpty<A>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
struct IsAlwaysEqualBase<A, true> {
|
struct IsAlwaysEqualBase<A, true> {
|
||||||
typedef typename A::IsAlwaysEqual Type;
|
using Type = typename A::IsAlwaysEqual;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
|
92
octa/range.h
92
octa/range.h
|
@ -27,11 +27,11 @@ template<typename T> struct RangeHalf;
|
||||||
namespace detail { \
|
namespace detail { \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
struct Range##Name##Base { \
|
struct Range##Name##Base { \
|
||||||
typedef typename T::TypeName Type; \
|
using Type = typename T::TypeName; \
|
||||||
}; \
|
}; \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
struct Range##Name##Base<RangeHalf<T>> { \
|
struct Range##Name##Base<RangeHalf<T>> { \
|
||||||
typedef typename T::TypeName Type; \
|
using Type = typename T::TypeName; \
|
||||||
}; \
|
}; \
|
||||||
} \
|
} \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
|
@ -146,7 +146,7 @@ struct RangeHalf {
|
||||||
private:
|
private:
|
||||||
T p_range;
|
T p_range;
|
||||||
public:
|
public:
|
||||||
typedef T Range;
|
using Range = T;
|
||||||
|
|
||||||
RangeHalf(): p_range() {}
|
RangeHalf(): p_range() {}
|
||||||
RangeHalf(const T &range): p_range(range) {}
|
RangeHalf(const T &range): p_range(range) {}
|
||||||
|
@ -287,11 +287,11 @@ namespace detail {
|
||||||
template<typename B, typename C, typename V, typename R = V &,
|
template<typename B, typename C, typename V, typename R = V &,
|
||||||
typename S = size_t, typename D = ptrdiff_t
|
typename S = size_t, typename D = ptrdiff_t
|
||||||
> struct InputRange {
|
> struct InputRange {
|
||||||
typedef C Category;
|
using Category = C;
|
||||||
typedef S Size;
|
using Size = S;
|
||||||
typedef D Difference;
|
using Difference = D;
|
||||||
typedef V Value;
|
using Value = V;
|
||||||
typedef R Reference;
|
using Reference = R;
|
||||||
|
|
||||||
octa::detail::RangeIterator<B> begin() const {
|
octa::detail::RangeIterator<B> begin() const {
|
||||||
return octa::detail::RangeIterator<B>((const B &)*this);
|
return octa::detail::RangeIterator<B>((const B &)*this);
|
||||||
|
@ -328,11 +328,11 @@ template<typename B, typename C, typename V, typename R = V &,
|
||||||
template<typename V, typename R = V &, typename S = size_t,
|
template<typename V, typename R = V &, typename S = size_t,
|
||||||
typename D = ptrdiff_t
|
typename D = ptrdiff_t
|
||||||
> struct OutputRange {
|
> struct OutputRange {
|
||||||
typedef OutputRangeTag Category;
|
using Category = OutputRangeTag;
|
||||||
typedef S Size;
|
using Size = S;
|
||||||
typedef D Difference;
|
using Difference = D;
|
||||||
typedef V Value;
|
using Value = V;
|
||||||
typedef R Reference;
|
using Reference = R;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -341,8 +341,8 @@ struct ReverseRange: InputRange<ReverseRange<T>,
|
||||||
RangeDifference<T>
|
RangeDifference<T>
|
||||||
> {
|
> {
|
||||||
private:
|
private:
|
||||||
typedef RangeReference<T> r_ref;
|
using Rref = RangeReference<T>;
|
||||||
typedef RangeSize<T> r_size;
|
using Rsize = RangeSize<T>;
|
||||||
|
|
||||||
T p_range;
|
T p_range;
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const { return p_range.empty(); }
|
bool empty() const { return p_range.empty(); }
|
||||||
r_size size() const { return p_range.size(); }
|
Rsize size() const { return p_range.size(); }
|
||||||
|
|
||||||
bool equals_front(const ReverseRange &r) const {
|
bool equals_front(const ReverseRange &r) const {
|
||||||
return p_range.equals_back(r.p_range);
|
return p_range.equals_back(r.p_range);
|
||||||
|
@ -395,19 +395,19 @@ public:
|
||||||
bool push_front() { return p_range.push_back(); }
|
bool push_front() { return p_range.push_back(); }
|
||||||
bool push_back() { return p_range.push_front(); }
|
bool push_back() { return p_range.push_front(); }
|
||||||
|
|
||||||
r_size pop_front_n(r_size n) { return p_range.pop_front_n(n); }
|
Rsize pop_front_n(Rsize n) { return p_range.pop_front_n(n); }
|
||||||
r_size pop_back_n(r_size n) { return p_range.pop_back_n(n); }
|
Rsize pop_back_n(Rsize n) { return p_range.pop_back_n(n); }
|
||||||
|
|
||||||
r_size push_front_n(r_size n) { return p_range.push_front_n(n); }
|
Rsize push_front_n(Rsize n) { return p_range.push_front_n(n); }
|
||||||
r_size push_back_n(r_size n) { return p_range.push_back_n(n); }
|
Rsize push_back_n(Rsize n) { return p_range.push_back_n(n); }
|
||||||
|
|
||||||
r_ref front() const { return p_range.back(); }
|
Rref front() const { return p_range.back(); }
|
||||||
r_ref back() const { return p_range.front(); }
|
Rref back() const { return p_range.front(); }
|
||||||
|
|
||||||
r_ref operator[](r_size i) const { return p_range[size() - i - 1]; }
|
Rref operator[](Rsize i) const { return p_range[size() - i - 1]; }
|
||||||
|
|
||||||
ReverseRange<T> slice(r_size start, r_size end) const {
|
ReverseRange<T> slice(Rsize start, Rsize end) const {
|
||||||
r_size len = p_range.size();
|
Rsize len = p_range.size();
|
||||||
return ReverseRange<T>(p_range.slice(len - end, len - start));
|
return ReverseRange<T>(p_range.slice(len - end, len - start));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -423,9 +423,9 @@ struct MoveRange: InputRange<MoveRange<T>,
|
||||||
RangeDifference<T>
|
RangeDifference<T>
|
||||||
> {
|
> {
|
||||||
private:
|
private:
|
||||||
typedef RangeValue<T> r_val;
|
using Rval = RangeValue<T>;
|
||||||
typedef RangeValue<T> &&r_ref;
|
using Rref = RangeValue<T> &&;
|
||||||
typedef RangeSize<T> r_size;
|
using Rsize = RangeSize<T>;
|
||||||
|
|
||||||
T p_range;
|
T p_range;
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const { return p_range.empty(); }
|
bool empty() const { return p_range.empty(); }
|
||||||
r_size size() const { return p_range.size(); }
|
Rsize size() const { return p_range.size(); }
|
||||||
|
|
||||||
bool equals_front(const MoveRange &r) const {
|
bool equals_front(const MoveRange &r) const {
|
||||||
return p_range.equals_front(r.p_range);
|
return p_range.equals_front(r.p_range);
|
||||||
|
@ -478,23 +478,23 @@ public:
|
||||||
bool push_front() { return p_range.push_front(); }
|
bool push_front() { return p_range.push_front(); }
|
||||||
bool push_back() { return p_range.push_back(); }
|
bool push_back() { return p_range.push_back(); }
|
||||||
|
|
||||||
r_size pop_front_n(r_size n) { return p_range.pop_front_n(n); }
|
Rsize pop_front_n(Rsize n) { return p_range.pop_front_n(n); }
|
||||||
r_size pop_back_n(r_size n) { return p_range.pop_back_n(n); }
|
Rsize pop_back_n(Rsize n) { return p_range.pop_back_n(n); }
|
||||||
|
|
||||||
r_size push_front_n(r_size n) { return p_range.push_front_n(n); }
|
Rsize push_front_n(Rsize n) { return p_range.push_front_n(n); }
|
||||||
r_size push_back_n(r_size n) { return p_range.push_back_n(n); }
|
Rsize push_back_n(Rsize n) { return p_range.push_back_n(n); }
|
||||||
|
|
||||||
r_ref front() const { return octa::move(p_range.front()); }
|
Rref front() const { return octa::move(p_range.front()); }
|
||||||
r_ref back() const { return octa::move(p_range.back()); }
|
Rref back() const { return octa::move(p_range.back()); }
|
||||||
|
|
||||||
r_ref operator[](r_size i) const { return octa::move(p_range[i]); }
|
Rref operator[](Rsize i) const { return octa::move(p_range[i]); }
|
||||||
|
|
||||||
MoveRange<T> slice(r_size start, r_size end) const {
|
MoveRange<T> slice(Rsize start, Rsize end) const {
|
||||||
return MoveRange<T>(p_range.slice(start, end));
|
return MoveRange<T>(p_range.slice(start, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
void put(const r_val &v) { p_range.put(v); }
|
void put(const Rval &v) { p_range.put(v); }
|
||||||
void put(r_val &&v) { p_range.put(octa::move(v)); }
|
void put(Rval &&v) { p_range.put(octa::move(v)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -653,11 +653,11 @@ struct EnumeratedRange: InputRange<EnumeratedRange<T>,
|
||||||
RangeSize<T>
|
RangeSize<T>
|
||||||
> {
|
> {
|
||||||
private:
|
private:
|
||||||
typedef RangeReference<T> r_ref;
|
using Rref = RangeReference<T>;
|
||||||
typedef RangeSize<T> r_size;
|
using Rsize = RangeSize<T>;
|
||||||
|
|
||||||
T p_range;
|
T p_range;
|
||||||
r_size p_index;
|
Rsize p_index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EnumeratedRange(): p_range(), p_index(0) {}
|
EnumeratedRange(): p_range(), p_index(0) {}
|
||||||
|
@ -705,14 +705,14 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
r_size pop_front_n(r_size n) {
|
Rsize pop_front_n(Rsize n) {
|
||||||
r_size ret = p_range.pop_front_n(n);
|
Rsize ret = p_range.pop_front_n(n);
|
||||||
p_index += ret;
|
p_index += ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumeratedValue<r_ref, r_size> front() const {
|
EnumeratedValue<Rref, Rsize> front() const {
|
||||||
return EnumeratedValue<r_ref, r_size> { p_index, p_range.front() };
|
return EnumeratedValue<Rref, Rsize> { p_index, p_range.front() };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,16 @@ class StringBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef size_t Size;
|
using Size = size_t;
|
||||||
typedef ptrdiff_t Difference;
|
using Difference = ptrdiff_t;
|
||||||
typedef T Value;
|
using Value = T;
|
||||||
typedef T &Reference;
|
using Reference = T &;
|
||||||
typedef const T &ConstReference;
|
using ConstReference = const T &;
|
||||||
typedef T *Pointer;
|
using Pointer = T *;
|
||||||
typedef const T *ConstPointer;
|
using ConstPointer = const T *;
|
||||||
typedef PointerRange< T> Range;
|
using Range = PointerRange<T>;
|
||||||
typedef PointerRange<const T> ConstRange;
|
using ConstRange = PointerRange<const T>;
|
||||||
typedef A Allocator;
|
using Allocator = A;
|
||||||
|
|
||||||
StringBase(const A &a = A()): p_buf(1, '\0', a) {}
|
StringBase(const A &a = A()): p_buf(1, '\0', a) {}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef StringBase<char> String;
|
using String = StringBase<char>;
|
||||||
|
|
||||||
template<typename T, typename F>
|
template<typename T, typename F>
|
||||||
String concat(const T v, const String &sep, F func) {
|
String concat(const T v, const String &sep, F func) {
|
||||||
|
@ -228,8 +228,8 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> struct ToString {
|
template<typename T> struct ToString {
|
||||||
typedef T Argument;
|
using Argument = T;
|
||||||
typedef String Result;
|
using Result = String;
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
static String to_str(const U &v,
|
static String to_str(const U &v,
|
||||||
|
@ -286,16 +286,16 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> struct ToString<bool> {
|
template<> struct ToString<bool> {
|
||||||
typedef bool Argument;
|
using Argument = bool;
|
||||||
typedef String Result;
|
using Result = String;
|
||||||
String operator()(bool b) {
|
String operator()(bool b) {
|
||||||
return b ? "true" : "false";
|
return b ? "true" : "false";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ToString<char> {
|
template<> struct ToString<char> {
|
||||||
typedef char Argument;
|
using Argument = char;
|
||||||
typedef String Result;
|
using Result = String;
|
||||||
String operator()(char c) {
|
String operator()(char c) {
|
||||||
String ret;
|
String ret;
|
||||||
ret.push(c);
|
ret.push(c);
|
||||||
|
@ -305,8 +305,8 @@ template<> struct ToString<char> {
|
||||||
|
|
||||||
#define OCTA_TOSTR_NUM(T, fmt) \
|
#define OCTA_TOSTR_NUM(T, fmt) \
|
||||||
template<> struct ToString<T> { \
|
template<> struct ToString<T> { \
|
||||||
typedef T Argument; \
|
using Argument = T; \
|
||||||
typedef String Result; \
|
using Result = String; \
|
||||||
String operator()(T v) { \
|
String operator()(T v) { \
|
||||||
String ret; \
|
String ret; \
|
||||||
octa::detail::str_printf((octa::Vector<char> *)&ret, fmt, v); \
|
octa::detail::str_printf((octa::Vector<char> *)&ret, fmt, v); \
|
||||||
|
@ -328,8 +328,8 @@ OCTA_TOSTR_NUM(ldouble, "%Lf")
|
||||||
#undef OCTA_TOSTR_NUM
|
#undef OCTA_TOSTR_NUM
|
||||||
|
|
||||||
template<typename T> struct ToString<T *> {
|
template<typename T> struct ToString<T *> {
|
||||||
typedef T *Argument;
|
using Argument = T *;
|
||||||
typedef String Result;
|
using Result = String;
|
||||||
String operator()(Argument v) {
|
String operator()(Argument v) {
|
||||||
String ret;
|
String ret;
|
||||||
octa::detail::str_printf((octa::Vector<char> *)&ret, "%p", v);
|
octa::detail::str_printf((octa::Vector<char> *)&ret, "%p", v);
|
||||||
|
@ -338,16 +338,16 @@ template<typename T> struct ToString<T *> {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct ToString<String> {
|
template<> struct ToString<String> {
|
||||||
typedef const String &Argument;
|
using Argument = const String &;
|
||||||
typedef String Result;
|
using Result = String;
|
||||||
String operator()(Argument s) {
|
String operator()(Argument s) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U> struct ToString<octa::Pair<T, U>> {
|
template<typename T, typename U> struct ToString<octa::Pair<T, U>> {
|
||||||
typedef const octa::Pair<T, U> &Argument;
|
using Argument = const octa::Pair<T, U> &;
|
||||||
typedef String Result;
|
using Result = String;
|
||||||
String operator()(Argument v) {
|
String operator()(Argument v) {
|
||||||
String ret("{");
|
String ret("{");
|
||||||
ret += ToString<octa::RemoveCv<octa::RemoveReference<T>>>()
|
ret += ToString<octa::RemoveCv<octa::RemoveReference<T>>>()
|
||||||
|
|
|
@ -55,15 +55,15 @@ template<typename T, T val>
|
||||||
struct IntegralConstant {
|
struct IntegralConstant {
|
||||||
static constexpr T value = val;
|
static constexpr T value = val;
|
||||||
|
|
||||||
typedef T Value;
|
using Value = T;
|
||||||
typedef IntegralConstant<T, val> Type;
|
using Type = IntegralConstant<T, val>;
|
||||||
|
|
||||||
constexpr operator Value() const { return value; }
|
constexpr operator Value() const { return value; }
|
||||||
constexpr Value operator()() const { return value; }
|
constexpr Value operator()() const { return value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef IntegralConstant<bool, true> True;
|
using True = IntegralConstant<bool, true>;
|
||||||
typedef IntegralConstant<bool, false> False;
|
using False = IntegralConstant<bool, false>;
|
||||||
|
|
||||||
template<typename T, T val> constexpr T IntegralConstant<T, val>::value;
|
template<typename T, T val> constexpr T IntegralConstant<T, val>::value;
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ struct HasVirtualDestructor: IntegralConstant<bool,
|
||||||
namespace detail {
|
namespace detail {
|
||||||
#define OCTA_MOVE(v) static_cast<octa::RemoveReference<decltype(v)> &&>(v)
|
#define OCTA_MOVE(v) static_cast<octa::RemoveReference<decltype(v)> &&>(v)
|
||||||
|
|
||||||
template<typename, typename T> struct Select2nd { typedef T Type; };
|
template<typename, typename T> struct Select2nd { using Type = T; };
|
||||||
struct Any { Any(...); };
|
struct Any { Any(...); };
|
||||||
|
|
||||||
template<typename T, typename ...A> typename Select2nd<
|
template<typename T, typename ...A> typename Select2nd<
|
||||||
|
@ -482,7 +482,7 @@ template<typename T> struct IsMoveAssignable: IsAssignable<
|
||||||
/* is destructible */
|
/* is destructible */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename> struct IsDtibleApply { typedef int Type; };
|
template<typename> struct IsDtibleApply { using Type = int; };
|
||||||
|
|
||||||
template<typename T> struct IsDestructorWellformed {
|
template<typename T> struct IsDestructorWellformed {
|
||||||
template<typename TT> static char test(typename IsDtibleApply<
|
template<typename TT> static char test(typename IsDtibleApply<
|
||||||
|
@ -619,7 +619,7 @@ namespace detail {
|
||||||
template<typename F, typename T, bool = octa::IsVoid<F>::value
|
template<typename F, typename T, bool = octa::IsVoid<F>::value
|
||||||
|| octa::IsFunction<T>::value || octa::IsArray<T>::value
|
|| octa::IsFunction<T>::value || octa::IsArray<T>::value
|
||||||
> struct IsConvertibleBase {
|
> struct IsConvertibleBase {
|
||||||
typedef typename octa::IsVoid<T>::Type Type;
|
using Type = typename octa::IsVoid<T>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename F, typename T>
|
template<typename F, typename T>
|
||||||
|
@ -632,7 +632,7 @@ namespace detail {
|
||||||
|
|
||||||
template<typename, typename> static octa::False test(...);
|
template<typename, typename> static octa::False test(...);
|
||||||
|
|
||||||
typedef decltype(test<F, T>(0)) Type;
|
using Type = decltype(test<F, T>(0));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,14 +675,14 @@ struct Rank<T[N]>: IntegralConstant<size_t, Rank<T>::value + 1> {};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveConstBase { typedef T Type; };
|
struct RemoveConstBase { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveConstBase<const T> { typedef T Type; };
|
struct RemoveConstBase<const T> { using Type = T; };
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveVolatileBase { typedef T Type; };
|
struct RemoveVolatileBase { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveVolatileBase<volatile T> { typedef T Type; };
|
struct RemoveVolatileBase<volatile T> { using Type = T; };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -693,7 +693,7 @@ using RemoveVolatile = typename octa::detail::RemoveVolatileBase<T>::Type;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveCvBase {
|
struct RemoveCvBase {
|
||||||
typedef octa::RemoveVolatile<octa::RemoveConst<T>> Type;
|
using Type = octa::RemoveVolatile<octa::RemoveConst<T>>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,26 +702,26 @@ namespace detail {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, bool = octa::IsReference<T>::value
|
template<typename T, bool = octa::IsReference<T>::value
|
||||||
|| octa::IsFunction<T>::value || octa::IsConst<T>::value>
|
|| octa::IsFunction<T>::value || octa::IsConst<T>::value>
|
||||||
struct AddConstCore { typedef T Type; };
|
struct AddConstCore { using Type = T; };
|
||||||
|
|
||||||
template<typename T> struct AddConstCore<T, false> {
|
template<typename T> struct AddConstCore<T, false> {
|
||||||
typedef const T Type;
|
using Type = const T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct AddConstBase {
|
template<typename T> struct AddConstBase {
|
||||||
typedef typename AddConstCore<T>::Type Type;
|
using Type = typename AddConstCore<T>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, bool = octa::IsReference<T>::value
|
template<typename T, bool = octa::IsReference<T>::value
|
||||||
|| octa::IsFunction<T>::value || octa::IsVolatile<T>::value>
|
|| octa::IsFunction<T>::value || octa::IsVolatile<T>::value>
|
||||||
struct AddVolatileCore { typedef T Type; };
|
struct AddVolatileCore { using Type = T; };
|
||||||
|
|
||||||
template<typename T> struct AddVolatileCore<T, false> {
|
template<typename T> struct AddVolatileCore<T, false> {
|
||||||
typedef volatile T Type;
|
using Type = volatile T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct AddVolatileBase {
|
template<typename T> struct AddVolatileBase {
|
||||||
typedef typename AddVolatileCore<T>::Type Type;
|
using Type = typename AddVolatileCore<T>::Type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ using AddVolatile = typename octa::detail::AddVolatileBase<T>::Type;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct AddCvBase {
|
struct AddCvBase {
|
||||||
typedef octa::AddConst<octa::AddVolatile<T>> Type;
|
using Type = octa::AddConst<octa::AddVolatile<T>>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,26 +742,26 @@ using AddCv = typename octa::detail::AddCvBase<T>::Type;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveReferenceBase { typedef T Type; };
|
struct RemoveReferenceBase { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveReferenceBase<T &> { typedef T Type; };
|
struct RemoveReferenceBase<T &> { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveReferenceBase<T &&> { typedef T Type; };
|
struct RemoveReferenceBase<T &&> { using Type = T; };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove pointer */
|
/* remove pointer */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemovePointerBase { typedef T Type; };
|
struct RemovePointerBase { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemovePointerBase<T * > { typedef T Type; };
|
struct RemovePointerBase<T * > { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemovePointerBase<T * const > { typedef T Type; };
|
struct RemovePointerBase<T * const > { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemovePointerBase<T * volatile > { typedef T Type; };
|
struct RemovePointerBase<T * volatile > { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemovePointerBase<T * const volatile> { typedef T Type; };
|
struct RemovePointerBase<T * const volatile> { using Type = T; };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -771,7 +771,7 @@ using RemovePointer = typename octa::detail::RemovePointerBase<T>::Type;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T> struct AddPointerBase {
|
template<typename T> struct AddPointerBase {
|
||||||
typedef octa::RemoveReference<T> *Type;
|
using Type = octa::RemoveReference<T> *;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,40 +781,40 @@ using AddPointer = typename octa::detail::AddPointerBase<T>::Type;
|
||||||
/* add lvalue reference */
|
/* add lvalue reference */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T> struct AddLr { typedef T &Type; };
|
template<typename T> struct AddLr { using Type = T &; };
|
||||||
template<typename T> struct AddLr<T &> { typedef T &Type; };
|
template<typename T> struct AddLr<T &> { using Type = T &; };
|
||||||
template<typename T> struct AddLr<T &&> { typedef T &Type; };
|
template<typename T> struct AddLr<T &&> { using Type = T &; };
|
||||||
template<> struct AddLr<void> {
|
template<> struct AddLr<void> {
|
||||||
typedef void Type;
|
using Type = void;
|
||||||
};
|
};
|
||||||
template<> struct AddLr<const void> {
|
template<> struct AddLr<const void> {
|
||||||
typedef const void Type;
|
using Type = const void;
|
||||||
};
|
};
|
||||||
template<> struct AddLr<volatile void> {
|
template<> struct AddLr<volatile void> {
|
||||||
typedef volatile void Type;
|
using Type = volatile void;
|
||||||
};
|
};
|
||||||
template<> struct AddLr<const volatile void> {
|
template<> struct AddLr<const volatile void> {
|
||||||
typedef const volatile void Type;
|
using Type = const volatile void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add rvalue reference */
|
/* add rvalue reference */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T> struct AddRr { typedef T &&Type; };
|
template<typename T> struct AddRr { using Type = T &&; };
|
||||||
template<typename T> struct AddRr<T &> { typedef T &&Type; };
|
template<typename T> struct AddRr<T &> { using Type = T &&; };
|
||||||
template<typename T> struct AddRr<T &&> { typedef T &&Type; };
|
template<typename T> struct AddRr<T &&> { using Type = T &&; };
|
||||||
template<> struct AddRr<void> {
|
template<> struct AddRr<void> {
|
||||||
typedef void Type;
|
using Type = void;
|
||||||
};
|
};
|
||||||
template<> struct AddRr<const void> {
|
template<> struct AddRr<const void> {
|
||||||
typedef const void Type;
|
using Type = const void;
|
||||||
};
|
};
|
||||||
template<> struct AddRr<volatile void> {
|
template<> struct AddRr<volatile void> {
|
||||||
typedef volatile void Type;
|
using Type = volatile void;
|
||||||
};
|
};
|
||||||
template<> struct AddRr<const volatile void> {
|
template<> struct AddRr<const volatile void> {
|
||||||
typedef const volatile void Type;
|
using Type = const volatile void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,11 +822,11 @@ namespace detail {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveExtentBase { typedef T Type; };
|
struct RemoveExtentBase { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveExtentBase<T[ ]> { typedef T Type; };
|
struct RemoveExtentBase<T[ ]> { using Type = T; };
|
||||||
template<typename T, size_t N>
|
template<typename T, size_t N>
|
||||||
struct RemoveExtentBase<T[N]> { typedef T Type; };
|
struct RemoveExtentBase<T[N]> { using Type = T; };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -835,14 +835,14 @@ using RemoveExtent = typename octa::detail::RemoveExtentBase<T>::Type;
|
||||||
/* remove all extents */
|
/* remove all extents */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T> struct RemoveAllExtentsBase { typedef T Type; };
|
template<typename T> struct RemoveAllExtentsBase { using Type = T; };
|
||||||
|
|
||||||
template<typename T> struct RemoveAllExtentsBase<T[]> {
|
template<typename T> struct RemoveAllExtentsBase<T[]> {
|
||||||
typedef RemoveAllExtentsBase<T> Type;
|
using Type = RemoveAllExtentsBase<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, size_t N> struct RemoveAllExtentsBase<T[N]> {
|
template<typename T, size_t N> struct RemoveAllExtentsBase<T[N]> {
|
||||||
typedef RemoveAllExtentsBase<T> Type;
|
using Type = RemoveAllExtentsBase<T>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,8 +854,8 @@ namespace detail {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, typename U> struct TypeList {
|
template<typename T, typename U> struct TypeList {
|
||||||
typedef T first;
|
using First = T;
|
||||||
typedef U rest;
|
using Rest = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* not a type */
|
/* not a type */
|
||||||
|
@ -866,66 +866,66 @@ namespace detail {
|
||||||
~TlNat() = delete;
|
~TlNat() = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TypeList<schar,
|
using Stypes = TypeList<schar,
|
||||||
TypeList<short,
|
TypeList<short,
|
||||||
TypeList<int,
|
TypeList<int,
|
||||||
TypeList<long,
|
TypeList<long,
|
||||||
TypeList<llong, TlNat>>>>> stypes;
|
TypeList<llong, TlNat>>>>>;
|
||||||
|
|
||||||
typedef TypeList<uchar,
|
using Utypes = TypeList<uchar,
|
||||||
TypeList<ushort,
|
TypeList<ushort,
|
||||||
TypeList<uint,
|
TypeList<uint,
|
||||||
TypeList<ulong,
|
TypeList<ulong,
|
||||||
TypeList<ullong, TlNat>>>>> utypes;
|
TypeList<ullong, TlNat>>>>>;
|
||||||
|
|
||||||
template<typename T, size_t N, bool = (N <= sizeof(typename T::first))>
|
template<typename T, size_t N, bool = (N <= sizeof(typename T::First))>
|
||||||
struct TypeFindFirst;
|
struct TypeFindFirst;
|
||||||
|
|
||||||
template<typename T, typename U, size_t N>
|
template<typename T, typename U, size_t N>
|
||||||
struct TypeFindFirst<TypeList<T, U>, N, true> {
|
struct TypeFindFirst<TypeList<T, U>, N, true> {
|
||||||
typedef T Type;
|
using Type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U, size_t N>
|
template<typename T, typename U, size_t N>
|
||||||
struct TypeFindFirst<TypeList<T, U>, N, false> {
|
struct TypeFindFirst<TypeList<T, U>, N, false> {
|
||||||
typedef typename TypeFindFirst<U, N>::Type Type;
|
using Type = typename TypeFindFirst<U, N>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U,
|
template<typename T, typename U,
|
||||||
bool = octa::IsConst<octa::RemoveReference<T>>::value,
|
bool = octa::IsConst<octa::RemoveReference<T>>::value,
|
||||||
bool = octa::IsVolatile<octa::RemoveReference<T>>::value
|
bool = octa::IsVolatile<octa::RemoveReference<T>>::value
|
||||||
> struct ApplyCv {
|
> struct ApplyCv {
|
||||||
typedef U Type;
|
using Type = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ApplyCv<T, U, true, false> { /* const */
|
struct ApplyCv<T, U, true, false> { /* const */
|
||||||
typedef const U Type;
|
using Type = const U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ApplyCv<T, U, false, true> { /* volatile */
|
struct ApplyCv<T, U, false, true> { /* volatile */
|
||||||
typedef volatile U Type;
|
using Type = volatile U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ApplyCv<T, U, true, true> { /* const volatile */
|
struct ApplyCv<T, U, true, true> { /* const volatile */
|
||||||
typedef const volatile U Type;
|
using Type = const volatile U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ApplyCv<T &, U, true, false> { /* const */
|
struct ApplyCv<T &, U, true, false> { /* const */
|
||||||
typedef const U &Type;
|
using Type = const U &;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ApplyCv<T &, U, false, true> { /* volatile */
|
struct ApplyCv<T &, U, false, true> { /* volatile */
|
||||||
typedef volatile U &Type;
|
using Type = volatile U &;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ApplyCv<T &, U, true, true> { /* const volatile */
|
struct ApplyCv<T &, U, true, true> { /* const volatile */
|
||||||
typedef const volatile U &Type;
|
using Type = const volatile U &;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, bool = octa::IsIntegral<T>::value ||
|
template<typename T, bool = octa::IsIntegral<T>::value ||
|
||||||
|
@ -938,48 +938,48 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct MakeSigned<T, true> {
|
struct MakeSigned<T, true> {
|
||||||
typedef typename TypeFindFirst<stypes, sizeof(T)>::Type Type;
|
using Type = typename TypeFindFirst<Stypes, sizeof(T)>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct MakeUnsigned<T, true> {
|
struct MakeUnsigned<T, true> {
|
||||||
typedef typename TypeFindFirst<utypes, sizeof(T)>::Type Type;
|
using Type = typename TypeFindFirst<Utypes, sizeof(T)>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct MakeSigned<bool , true> {};
|
template<> struct MakeSigned<bool , true> {};
|
||||||
template<> struct MakeSigned<schar , true> { typedef schar Type; };
|
template<> struct MakeSigned<schar , true> { using Type = schar; };
|
||||||
template<> struct MakeSigned<uchar , true> { typedef schar Type; };
|
template<> struct MakeSigned<uchar , true> { using Type = schar; };
|
||||||
template<> struct MakeSigned<short , true> { typedef short Type; };
|
template<> struct MakeSigned<short , true> { using Type = short; };
|
||||||
template<> struct MakeSigned<ushort, true> { typedef short Type; };
|
template<> struct MakeSigned<ushort, true> { using Type = short; };
|
||||||
template<> struct MakeSigned<int , true> { typedef int Type; };
|
template<> struct MakeSigned<int , true> { using Type = int; };
|
||||||
template<> struct MakeSigned<uint , true> { typedef int Type; };
|
template<> struct MakeSigned<uint , true> { using Type = int; };
|
||||||
template<> struct MakeSigned<long , true> { typedef long Type; };
|
template<> struct MakeSigned<long , true> { using Type = long; };
|
||||||
template<> struct MakeSigned<ulong , true> { typedef long Type; };
|
template<> struct MakeSigned<ulong , true> { using Type = long; };
|
||||||
template<> struct MakeSigned<llong , true> { typedef llong Type; };
|
template<> struct MakeSigned<llong , true> { using Type = llong; };
|
||||||
template<> struct MakeSigned<ullong, true> { typedef llong Type; };
|
template<> struct MakeSigned<ullong, true> { using Type = llong; };
|
||||||
|
|
||||||
template<> struct MakeUnsigned<bool , true> {};
|
template<> struct MakeUnsigned<bool , true> {};
|
||||||
template<> struct MakeUnsigned<schar , true> { typedef uchar Type; };
|
template<> struct MakeUnsigned<schar , true> { using Type = uchar; };
|
||||||
template<> struct MakeUnsigned<uchar , true> { typedef uchar Type; };
|
template<> struct MakeUnsigned<uchar , true> { using Type = uchar; };
|
||||||
template<> struct MakeUnsigned<short , true> { typedef ushort Type; };
|
template<> struct MakeUnsigned<short , true> { using Type = ushort; };
|
||||||
template<> struct MakeUnsigned<ushort, true> { typedef ushort Type; };
|
template<> struct MakeUnsigned<ushort, true> { using Type = ushort; };
|
||||||
template<> struct MakeUnsigned<int , true> { typedef uint Type; };
|
template<> struct MakeUnsigned<int , true> { using Type = uint; };
|
||||||
template<> struct MakeUnsigned<uint , true> { typedef uint Type; };
|
template<> struct MakeUnsigned<uint , true> { using Type = uint; };
|
||||||
template<> struct MakeUnsigned<long , true> { typedef ulong Type; };
|
template<> struct MakeUnsigned<long , true> { using Type = ulong; };
|
||||||
template<> struct MakeUnsigned<ulong , true> { typedef ulong Type; };
|
template<> struct MakeUnsigned<ulong , true> { using Type = ulong; };
|
||||||
template<> struct MakeUnsigned<llong , true> { typedef ullong Type; };
|
template<> struct MakeUnsigned<llong , true> { using Type = ullong; };
|
||||||
template<> struct MakeUnsigned<ullong, true> { typedef ullong Type; };
|
template<> struct MakeUnsigned<ullong, true> { using Type = ullong; };
|
||||||
|
|
||||||
template<typename T> struct MakeSignedBase {
|
template<typename T> struct MakeSignedBase {
|
||||||
typedef typename ApplyCv<T,
|
using Type = typename ApplyCv<T,
|
||||||
typename MakeSigned<octa::RemoveCv<T>>::Type
|
typename MakeSigned<octa::RemoveCv<T>>::Type
|
||||||
>::Type Type;
|
>::Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct MakeUnsignedBase {
|
template<typename T> struct MakeUnsignedBase {
|
||||||
typedef typename ApplyCv<T,
|
using Type = typename ApplyCv<T,
|
||||||
typename MakeUnsigned<octa::RemoveCv<T>>::Type
|
typename MakeUnsigned<octa::RemoveCv<T>>::Type
|
||||||
>::Type Type;
|
>::Type;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -993,12 +993,12 @@ using MakeUnsigned = typename octa::detail::MakeUnsignedBase<T>::Type;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<bool _cond, typename T, typename U>
|
template<bool _cond, typename T, typename U>
|
||||||
struct ConditionalBase {
|
struct ConditionalBase {
|
||||||
typedef T Type;
|
using Type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct ConditionalBase<false, T, U> {
|
struct ConditionalBase<false, T, U> {
|
||||||
typedef U Type;
|
using Type = U;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,7 +1058,7 @@ using ResultOf = typename octa::detail::ResultOfBase<T>::Type;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<bool B, typename T = void> struct EnableIfBase {};
|
template<bool B, typename T = void> struct EnableIfBase {};
|
||||||
|
|
||||||
template<typename T> struct EnableIfBase<true, T> { typedef T Type; };
|
template<typename T> struct EnableIfBase<true, T> { using Type = T; };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool B, typename T = void>
|
template<bool B, typename T = void>
|
||||||
|
@ -1070,13 +1070,13 @@ namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct DecayBase {
|
struct DecayBase {
|
||||||
private:
|
private:
|
||||||
typedef octa::RemoveReference<T> U;
|
using U = octa::RemoveReference<T>;
|
||||||
public:
|
public:
|
||||||
typedef octa::Conditional<octa::IsArray<U>::value,
|
using Type = octa::Conditional<octa::IsArray<U>::value,
|
||||||
octa::RemoveExtent<U> *,
|
octa::RemoveExtent<U> *,
|
||||||
octa::Conditional<octa::IsFunction<U>::value,
|
octa::Conditional<octa::IsFunction<U>::value,
|
||||||
octa::AddPointer<U>, octa::RemoveCv<U>>
|
octa::AddPointer<U>, octa::RemoveCv<U>>
|
||||||
> Type;
|
>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,18 +1089,19 @@ namespace detail {
|
||||||
template<typename ...T> struct CommonTypeBase;
|
template<typename ...T> struct CommonTypeBase;
|
||||||
|
|
||||||
template<typename T> struct CommonTypeBase<T> {
|
template<typename T> struct CommonTypeBase<T> {
|
||||||
typedef Decay<T> Type;
|
using Type = Decay<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U> struct CommonTypeBase<T, U> {
|
template<typename T, typename U> struct CommonTypeBase<T, U> {
|
||||||
typedef Decay<decltype(true ? octa::detail::declval_in<T>()
|
using Type = Decay<decltype(true ? octa::detail::declval_in<T>()
|
||||||
: octa::detail::declval_in<U>())> Type;
|
: octa::detail::declval_in<U>())>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U, typename ...V>
|
template<typename T, typename U, typename ...V>
|
||||||
struct CommonTypeBase<T, U, V...> {
|
struct CommonTypeBase<T, U, V...> {
|
||||||
typedef typename CommonTypeBase<typename CommonTypeBase<T, U>::Type,
|
using Type = typename CommonTypeBase<
|
||||||
V...>::Type Type;
|
typename CommonTypeBase<T, U>::Type, V...
|
||||||
|
>::Type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1167,7 @@ using AlignedUnion = typename octa::detail::AlignedUnionBase<N, T...>::Type;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
/* gotta wrap, in a struct otherwise clang ICEs... */
|
/* gotta wrap, in a struct otherwise clang ICEs... */
|
||||||
template<typename T> struct UnderlyingTypeBase {
|
template<typename T> struct UnderlyingTypeBase {
|
||||||
typedef __underlying_type(T) Type;
|
using Type = __underlying_type(T);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
octa/types.h
22
octa/types.h
|
@ -1,4 +1,4 @@
|
||||||
/* Core typedefs for OctaSTD.
|
/* Core type aliases for OctaSTD.
|
||||||
*
|
*
|
||||||
* This file is part of OctaSTD. See COPYING.md for futher information.
|
* This file is part of OctaSTD. See COPYING.md for futher information.
|
||||||
*/
|
*/
|
||||||
|
@ -11,22 +11,22 @@
|
||||||
|
|
||||||
namespace octa {
|
namespace octa {
|
||||||
|
|
||||||
typedef signed char schar;
|
using schar = signed char;
|
||||||
typedef unsigned char uchar;
|
using uchar = unsigned char;
|
||||||
typedef unsigned short ushort;
|
using ushort = unsigned short;
|
||||||
typedef unsigned int uint;
|
using uint = unsigned int;
|
||||||
typedef unsigned long ulong;
|
using ulong = unsigned long;
|
||||||
typedef unsigned long long ullong;
|
using ullong = unsigned long long;
|
||||||
typedef long long llong;
|
using llong = long long;
|
||||||
|
|
||||||
typedef long double ldouble;
|
using ldouble = long double;
|
||||||
|
|
||||||
typedef decltype(nullptr) nullptr_t;
|
using nullptr_t = decltype(nullptr);
|
||||||
|
|
||||||
#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
|
#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
|
||||||
using ::max_align_t;
|
using ::max_align_t;
|
||||||
#else
|
#else
|
||||||
typedef long double max_align_t;
|
using max_align_t = long double;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,17 +143,17 @@ template<typename T> struct ReferenceWrapper;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct MakePairRetBase {
|
struct MakePairRetBase {
|
||||||
typedef T Type;
|
using Type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct MakePairRetBase<ReferenceWrapper<T>> {
|
struct MakePairRetBase<ReferenceWrapper<T>> {
|
||||||
typedef T &Type;
|
using Type = T &;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct MakePairRet {
|
struct MakePairRet {
|
||||||
typedef typename octa::detail::MakePairRetBase<octa::Decay<T>>::Type Type;
|
using Type = typename octa::detail::MakePairRetBase<octa::Decay<T>>::Type;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,9 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, typename A = octa::Allocator<T>>
|
template<typename T, typename A = octa::Allocator<T>>
|
||||||
class Vector {
|
class Vector {
|
||||||
typedef octa::detail::VectorPair<T, A> _vp_type;
|
using VecPair = octa::detail::VectorPair<T, A>;
|
||||||
|
|
||||||
_vp_type p_buf;
|
VecPair p_buf;
|
||||||
size_t p_len, p_cap;
|
size_t p_len, p_cap;
|
||||||
|
|
||||||
void insert_base(size_t idx, size_t n) {
|
void insert_base(size_t idx, size_t n) {
|
||||||
|
@ -114,18 +114,16 @@ class Vector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { MIN_SIZE = 8 };
|
using Size = size_t;
|
||||||
|
using Difference = ptrdiff_t;
|
||||||
typedef size_t Size;
|
using Value = T;
|
||||||
typedef ptrdiff_t Difference;
|
using Reference = T &;
|
||||||
typedef T Value;
|
using ConstReference = const T &;
|
||||||
typedef T &Reference;
|
using Pointer = T *;
|
||||||
typedef const T &ConstReference;
|
using ConstPointer = const T *;
|
||||||
typedef T *Pointer;
|
using Range = PointerRange<T>;
|
||||||
typedef const T *ConstPointer;
|
using ConstRange = PointerRange<const T>;
|
||||||
typedef PointerRange< T> Range;
|
using Allocator = A;
|
||||||
typedef PointerRange<const T> ConstRange;
|
|
||||||
typedef A Allocator;
|
|
||||||
|
|
||||||
Vector(const A &a = A()): p_buf(nullptr, a), p_len(0), p_cap(0) {}
|
Vector(const A &a = A()): p_buf(nullptr, a), p_len(0), p_cap(0) {}
|
||||||
|
|
||||||
|
@ -176,7 +174,7 @@ public:
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new (&p_buf) _vp_type(v.p_buf.p_ptr,
|
new (&p_buf) VecPair(v.p_buf.p_ptr,
|
||||||
octa::move(v.p_buf.get_alloc()));
|
octa::move(v.p_buf.get_alloc()));
|
||||||
p_len = v.p_len;
|
p_len = v.p_len;
|
||||||
p_cap = v.p_cap;
|
p_cap = v.p_cap;
|
||||||
|
@ -227,8 +225,8 @@ public:
|
||||||
octa::allocator_deallocate(p_buf.get_alloc(), p_buf.p_ptr, p_cap);
|
octa::allocator_deallocate(p_buf.get_alloc(), p_buf.p_ptr, p_cap);
|
||||||
p_len = v.p_len;
|
p_len = v.p_len;
|
||||||
p_cap = v.p_cap;
|
p_cap = v.p_cap;
|
||||||
p_buf.~_vp_type();
|
p_buf.~VecPair();
|
||||||
new (&p_buf) _vp_type(v.disown(), octa::move(v.p_buf.get_alloc()));
|
new (&p_buf) VecPair(v.disown(), octa::move(v.p_buf.get_alloc()));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +274,7 @@ public:
|
||||||
if (n <= p_cap) return;
|
if (n <= p_cap) return;
|
||||||
size_t oc = p_cap;
|
size_t oc = p_cap;
|
||||||
if (!oc) {
|
if (!oc) {
|
||||||
p_cap = octa::max(n, size_t(MIN_SIZE));
|
p_cap = octa::max(n, size_t(8));
|
||||||
} else {
|
} else {
|
||||||
while (p_cap < n) p_cap *= 2;
|
while (p_cap < n) p_cap *= 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue