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