diff --git a/octa/array.h b/octa/array.h index 0e327ad..f77974a 100644 --- a/octa/array.h +++ b/octa/array.h @@ -16,15 +16,15 @@ namespace octa { template 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 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; + using ConstRange = PointerRange; T &operator[](size_t i) { return p_buf[i]; } const T &operator[](size_t i) const { return p_buf[i]; } diff --git a/octa/atomic.h b/octa/atomic.h index 09299a9..bfb345f 100644 --- a/octa/atomic.h +++ b/octa/atomic.h @@ -382,11 +382,11 @@ namespace detail { template struct Atomic: Atomic { - typedef Atomic _base_t; + using Base = Atomic; 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 struct Atomic: octa::detail::Atomic { - typedef octa::detail::Atomic _base_t; + using Base = octa::detail::Atomic; 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 struct Atomic: octa::detail::Atomic { - typedef octa::detail::Atomic _base_t; + using Base = octa::detail::Atomic; 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 AtomicBool; - typedef Atomic AtomicChar; - typedef Atomic AtomicSchar; - typedef Atomic AtomicUchar; - typedef Atomic AtomicShort; - typedef Atomic AtomicUshort; - typedef Atomic AtomicInt; - typedef Atomic AtomicUint; - typedef Atomic AtomicLong; - typedef Atomic AtomicUlong; - typedef Atomic AtomicLlong; - typedef Atomic AtomicUllong; + using AtomicBool = Atomic; + using AtomicChar = Atomic; + using AtomicSchar = Atomic; + using AtomicUchar = Atomic; + using AtomicShort = Atomic; + using AtomicUshort = Atomic; + using AtomicInt = Atomic; + using AtomicUint = Atomic; + using AtomicLong = Atomic; + using AtomicUlong = Atomic; + using AtomicLlong = Atomic; + using AtomicUllong = Atomic; - typedef Atomic AtomicChar16; - typedef Atomic AtomicChar32; - typedef Atomic< wchar_t> AtomicWchar; + using AtomicChar16 = Atomic; + using AtomicChar32 = Atomic; + using AtomicWchar = Atomic; - typedef Atomic< intptr_t> AtomicIntptr; - typedef Atomic AtomicUintptr; - typedef Atomic< size_t> AtomicSize; - typedef Atomic AtomicPtrdiff; + using AtomicIntptr = Atomic; + using AtomicUintptr = Atomic; + using AtomicSize = Atomic; + using AtomicPtrdiff = Atomic; #define ATOMIC_FLAG_INIT {false} #define ATOMIC_VAR_INIT(v) {v} diff --git a/octa/functional.h b/octa/functional.h index 6a7f2c6..7b50023 100644 --- a/octa/functional.h +++ b/octa/functional.h @@ -15,14 +15,14 @@ namespace octa { /* basic function objects */ -#define OCTA_DEFINE_BINARY_OP(_name, _op, _rettype) \ -template struct _name { \ - _rettype operator()(const T &x, const T &y) const { \ - return x _op y; \ +#define OCTA_DEFINE_BINARY_OP(name, op, RT) \ +template 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 struct LogicalNot { bool operator()(const T &x) const { return !x; } - typedef T Argument; - typedef bool Result; + using Argument = T; + using Result = bool; }; template struct Negate { bool operator()(const T &x) const { return -x; } - typedef T Argument; - typedef T Result; + using Argument = T; + using Result = T; }; template 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 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 struct Hash; namespace detail { template 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 struct ScalarHash { - 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 struct ScalarHash { - 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 struct ScalarHash { - 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 struct ScalarHash { - 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 struct ScalarHash { - 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: octa::detail::ScalarHash { }; template struct Hash { - 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 struct Hash { template 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 struct MemTypes; template struct MemTypes { - typedef R Result; - typedef T Argument; + using Result = R; + using Argument = T; }; template struct MemTypes { - typedef R Result; - typedef T FirstArgument; - typedef A SecondArgument; + using Result = R; + using FirstArgument = T; + using SecondArgument = A; }; template struct MemTypes { - typedef R Result; - typedef const T Argument; + using Result = R; + using Argument = const T; }; template struct MemTypes { - typedef R Result; - typedef const T FirstArgument; - typedef A SecondArgument; + using Result = R; + using FirstArgument = const T; + using SecondArgument = A; }; template @@ -488,9 +488,9 @@ namespace detail { template static void call_move_and_destroy(FmStorage &lhs, FmStorage &&rhs) { - typedef FunctorDataManager _spec; - _spec::move_f(lhs, octa::move(rhs)); - _spec::destroy_f(rhs.get_alloc(), rhs); + using Spec = FunctorDataManager; + Spec::move_f(lhs, octa::move(rhs)); + Spec::destroy_f(rhs.get_alloc(), rhs); create_fm(lhs, octa::move(rhs.get_alloc())); rhs.get_alloc().~A(); } @@ -498,22 +498,22 @@ namespace detail { template static void call_copy(FmStorage &lhs, const FmStorage &rhs) { - typedef FunctorDataManager _spec; + using Spec = FunctorDataManager; create_fm(lhs, A(rhs.get_alloc())); - _spec::store_f(lhs, _spec::get_ref(rhs)); + Spec::store_f(lhs, Spec::get_ref(rhs)); } template static void call_copy_fo(FmStorage &lhs, const FmStorage &rhs) { - typedef FunctorDataManager _spec; - _spec::store_f(lhs, _spec::get_ref(rhs)); + using Spec = FunctorDataManager; + Spec::store_f(lhs, Spec::get_ref(rhs)); } template static void call_destroy(FmStorage &s) { - typedef FunctorDataManager _spec; - _spec::destroy_f(s.get_alloc(), s); + using Spec = FunctorDataManager; + Spec::destroy_f(s.get_alloc(), s); s.get_alloc().~A(); } }; @@ -527,20 +527,20 @@ namespace detail { template struct FunctionBase { - typedef R Result; + using Result = R; }; template struct FunctionBase { - typedef R Result; - typedef T Argument; + using Result = R; + using Argument = T; }; template struct FunctionBase { - typedef R Result; - typedef T FirstArgument; - typedef U SecondArgument; + using Result = R; + using FirstArgument = T; + using SecondArgument = U; }; template @@ -638,7 +638,7 @@ struct Function: octa::detail::FunctionBase { return; } - typedef AllocatorRebind AA; + using AA = AllocatorRebind; const octa::detail::FunctionManager *mff = &octa::detail::get_default_fm(); if (f.p_stor.manager == mff) { @@ -712,8 +712,8 @@ private: } void init_empty() { - typedef R(*emptyf)(Args...); - typedef octa::Allocator emptya; + using emptyf = R(*)(Args...); + using emptya = octa::Allocator; p_call = nullptr; octa::detail::create_fm(p_stor, emptya()); octa::detail::FunctorDataManager::store_f(p_stor, @@ -756,8 +756,8 @@ namespace detail { template struct DcLambdaTypes { - typedef R (*Ptr)(A...); - typedef octa::Function Obj; + using Ptr = R (*)(A...); + using Obj = octa::Function; }; template @@ -771,33 +771,33 @@ namespace detail { template::value> struct DcFuncTypeObjBase { - typedef typename DcLambdaTypes::Obj Type; + using Type = typename DcLambdaTypes::Obj; }; template struct DcFuncTypeObjBase { - typedef typename DcLambdaTypes::Ptr Type; + using Type = typename DcLambdaTypes::Ptr; }; template::value && octa::IsMoveConstructible::value > struct DcFuncTypeObj { - typedef typename DcFuncTypeObjBase::Type Type; + using Type = typename DcFuncTypeObjBase::Type; }; template struct DcFuncTypeObj { - typedef F Type; + using Type = F; }; template::value> struct DcFuncType { - typedef F Type; + using Type = F; }; template struct DcFuncType { - typedef typename DcFuncTypeObj::Type Type; + using Type = typename DcFuncTypeObj::Type; }; } diff --git a/octa/memory.h b/octa/memory.h index c336714..4539f45 100644 --- a/octa/memory.h +++ b/octa/memory.h @@ -35,27 +35,27 @@ namespace detail { struct PointerElementBase; template struct PointerElementBase { - typedef typename T::Element Type; + using Type = typename T::Element; }; template class T, typename U, typename ...A> struct PointerElementBase, true> { - typedef typename T::Element Type; + using Type = typename T::Element; }; template class T, typename U, typename ...A> struct PointerElementBase, false> { - typedef U Type; + using Type = U; }; template struct PointerElementType { - typedef typename PointerElementBase::Type Type; + using Type = typename PointerElementBase::Type; }; template struct PointerElementType { - typedef T Type; + using Type = T; }; template @@ -68,21 +68,21 @@ namespace detail { template::value> struct PointerDifferenceBase { - typedef ptrdiff_t Type; + using Type = ptrdiff_t; }; template struct PointerDifferenceBase { - typedef typename T::Difference Type; + using Type = typename T::Difference; }; template struct PointerDifferenceType { - typedef typename PointerDifferenceBase::Type Type; + using Type = typename PointerDifferenceBase::Type; }; template struct PointerDifferenceType { - typedef ptrdiff_t Type; + using Type = ptrdiff_t; }; template @@ -96,21 +96,21 @@ namespace detail { template::value> struct PointerRebindBase { - typedef typename T::template Rebind Type; + using Type = typename T::template Rebind; }; template class T, typename U, typename ...A, typename V > struct PointerRebindBase, V, true> { - typedef typename T::template Rebind Type; + using Type = typename T::template Rebind; }; template class T, typename U, typename ...A, typename V > struct PointerRebindBase, V, false> { - typedef T Type; + using Type = T; }; template @@ -125,12 +125,12 @@ namespace detail { template struct PointerPointer { - typedef T Type; + using Type = T; }; template struct PointerPointer { - typedef T *Type; + using Type = T *; }; } /*namespace detail */ @@ -255,29 +255,29 @@ namespace detail { template::value> struct PointerBase { - typedef typename D::Pointer Type; + using Type = typename D::Pointer; }; template struct PointerBase { - typedef T *Type; + using Type = T *; }; template struct PointerType { - typedef typename PointerBase>::Type Type; + using Type = typename PointerBase>::Type; }; } /* namespace detail */ template> struct Box { - typedef T Element; - typedef D Deleter; - typedef typename octa::detail::PointerType::Type Pointer; + using Element = T; + using Deleter = D; + using Pointer = typename octa::detail::PointerType::Type; private: struct Nat { int x; }; - typedef RemoveReference &D_ref; - typedef const RemoveReference &D_cref; + using Dref = RemoveReference &; + using Dcref = const RemoveReference &; 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 struct Box { - typedef T Element; - typedef D Deleter; - typedef typename octa::detail::PointerType::Type Pointer; + using Element = T; + using Deleter = D; + using Pointer = typename octa::detail::PointerType::Type; private: struct Nat { int x; }; - typedef RemoveReference &D_ref; - typedef const RemoveReference &D_cref; + using Dref = RemoveReference &; + using Dcref = const RemoveReference &; 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 struct BoxIf { - typedef octa::Box Box; + using Box = octa::Box; }; template struct BoxIf { - typedef octa::Box BoxUnknownSize; + using BoxUnknownSize = octa::Box; }; template struct BoxIf { - typedef void BoxKnownSize; + using BoxKnownSize = void; }; } @@ -552,29 +552,29 @@ typename octa::detail::BoxIf::BoxKnownSize make_box(A &&...args) = delete; template struct Allocator; template<> struct Allocator { - typedef void Value; - typedef void *Pointer; - typedef const void *ConstPointer; + using Value = void; + using Pointer = void *; + using ConstPointer = const void *; template using Rebind = Allocator; }; template<> struct Allocator { - 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 using Rebind = Allocator; }; template 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 using Rebind = Allocator; @@ -602,13 +602,13 @@ template struct Allocator { }; template struct Allocator { - 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 using Rebind = Allocator; @@ -656,12 +656,12 @@ namespace detail { template::value> struct ConstPointer { - typedef typename A::ConstPointer Type; + using Type = typename A::ConstPointer; }; template struct ConstPointer { - typedef PointerRebind Type; + using Type = PointerRebind; }; template @@ -674,12 +674,12 @@ namespace detail { template::value> struct VoidPointer { - typedef typename A::VoidPointer Type; + using Type = typename A::VoidPointer; }; template struct VoidPointer { - typedef PointerRebind Type; + using Type = PointerRebind; }; template @@ -692,12 +692,12 @@ namespace detail { template::value> struct ConstVoidPointer { - typedef typename A::ConstVoidPointer Type; + using Type = typename A::ConstVoidPointer; }; template struct ConstVoidPointer { - typedef PointerRebind Type; + using Type = PointerRebind; }; template @@ -709,12 +709,12 @@ namespace detail { template::value> struct SizeBase { - typedef octa::MakeUnsigned Type; + using Type = octa::MakeUnsigned; }; template struct SizeBase { - typedef typename A::Size Type; + using Type = typename A::Size; }; } /* namespace detail */ @@ -758,12 +758,12 @@ namespace detail { template::value> struct AllocDifference { - typedef PointerDifference

Type; + using Type = PointerDifference

; }; template struct AllocDifference { - typedef typename A::Difference Type; + using Type = typename A::Difference; }; } @@ -784,21 +784,21 @@ using AllocatorSize = typename octa::detail::SizeBase< namespace detail { template::value> struct AllocTraitsRebindType { - typedef typename T::template Rebind Type; + using Type = typename T::template Rebind; }; template class A, typename T, typename ...Args, typename U > struct AllocTraitsRebindType, U, true> { - typedef typename A::template Rebind Type; + using Type = typename A::template Rebind; }; template class A, typename T, typename ...Args, typename U > struct AllocTraitsRebindType, U, false> { - typedef A Type; + using Type = A; }; } /* namespace detail */ @@ -821,12 +821,12 @@ namespace detail { template::value> struct PropagateOnContainerCopyAssignmentBase { - typedef octa::False Type; + using Type = octa::False; }; template struct PropagateOnContainerCopyAssignmentBase { - typedef typename A::PropagateOnContainerCopyAssignment Type; + using Type = typename A::PropagateOnContainerCopyAssignment; }; } /* namespace detail */ @@ -848,12 +848,12 @@ namespace detail { template::value> struct PropagateOnContainerMoveAssignmentBase { - typedef octa::False Type; + using Type = octa::False; }; template struct PropagateOnContainerMoveAssignmentBase { - typedef typename A::PropagateOnContainerMoveAssignment Type; + using Type = typename A::PropagateOnContainerMoveAssignment; }; } /* namespace detail */ @@ -874,12 +874,12 @@ namespace detail { template::value> struct PropagateOnContainerSwapBase { - typedef octa::False Type; + using Type = octa::False; }; template struct PropagateOnContainerSwapBase { - typedef typename A::PropagateOnContainerSwap Type; + using Type = typename A::PropagateOnContainerSwap; }; } /* namespace detail */ @@ -899,12 +899,12 @@ namespace detail { template::value> struct IsAlwaysEqualBase { - typedef typename octa::IsEmpty::Type Type; + using Type = typename octa::IsEmpty::Type; }; template struct IsAlwaysEqualBase { - typedef typename A::IsAlwaysEqual Type; + using Type = typename A::IsAlwaysEqual; }; } /* namespace detail */ diff --git a/octa/range.h b/octa/range.h index 3062f59..0ef8018 100644 --- a/octa/range.h +++ b/octa/range.h @@ -27,11 +27,11 @@ template struct RangeHalf; namespace detail { \ template \ struct Range##Name##Base { \ - typedef typename T::TypeName Type; \ + using Type = typename T::TypeName; \ }; \ template \ struct Range##Name##Base> { \ - typedef typename T::TypeName Type; \ + using Type = typename T::TypeName; \ }; \ } \ template \ @@ -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 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 begin() const { return octa::detail::RangeIterator((const B &)*this); @@ -328,11 +328,11 @@ template 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 @@ -341,8 +341,8 @@ struct ReverseRange: InputRange, RangeDifference > { private: - typedef RangeReference r_ref; - typedef RangeSize r_size; + using Rref = RangeReference; + using Rsize = RangeSize; 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 slice(r_size start, r_size end) const { - r_size len = p_range.size(); + ReverseRange slice(Rsize start, Rsize end) const { + Rsize len = p_range.size(); return ReverseRange(p_range.slice(len - end, len - start)); } }; @@ -423,9 +423,9 @@ struct MoveRange: InputRange, RangeDifference > { private: - typedef RangeValue r_val; - typedef RangeValue &&r_ref; - typedef RangeSize r_size; + using Rval = RangeValue; + using Rref = RangeValue &&; + using Rsize = RangeSize; 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 slice(r_size start, r_size end) const { + MoveRange slice(Rsize start, Rsize end) const { return MoveRange(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 @@ -653,11 +653,11 @@ struct EnumeratedRange: InputRange, RangeSize > { private: - typedef RangeReference r_ref; - typedef RangeSize r_size; + using Rref = RangeReference; + using Rsize = RangeSize; 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 front() const { - return EnumeratedValue { p_index, p_range.front() }; + EnumeratedValue front() const { + return EnumeratedValue { p_index, p_range.front() }; } }; diff --git a/octa/string.h b/octa/string.h index 484e8ef..ffe71d2 100644 --- a/octa/string.h +++ b/octa/string.h @@ -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 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; + using ConstRange = PointerRange; + using Allocator = A; StringBase(const A &a = A()): p_buf(1, '\0', a) {} @@ -177,7 +177,7 @@ public: } }; -typedef StringBase String; +using String = StringBase; template String concat(const T v, const String &sep, F func) { @@ -228,8 +228,8 @@ namespace detail { } template struct ToString { - typedef T Argument; - typedef String Result; + using Argument = T; + using Result = String; template static String to_str(const U &v, @@ -286,16 +286,16 @@ namespace detail { } template<> struct ToString { - typedef bool Argument; - typedef String Result; + using Argument = bool; + using Result = String; String operator()(bool b) { return b ? "true" : "false"; } }; template<> struct ToString { - 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 { #define OCTA_TOSTR_NUM(T, fmt) \ template<> struct ToString { \ - typedef T Argument; \ - typedef String Result; \ + using Argument = T; \ + using Result = String; \ String operator()(T v) { \ String ret; \ octa::detail::str_printf((octa::Vector *)&ret, fmt, v); \ @@ -328,8 +328,8 @@ OCTA_TOSTR_NUM(ldouble, "%Lf") #undef OCTA_TOSTR_NUM template struct ToString { - typedef T *Argument; - typedef String Result; + using Argument = T *; + using Result = String; String operator()(Argument v) { String ret; octa::detail::str_printf((octa::Vector *)&ret, "%p", v); @@ -338,16 +338,16 @@ template struct ToString { }; template<> struct ToString { - typedef const String &Argument; - typedef String Result; + using Argument = const String &; + using Result = String; String operator()(Argument s) { return s; } }; template struct ToString> { - typedef const octa::Pair &Argument; - typedef String Result; + using Argument = const octa::Pair &; + using Result = String; String operator()(Argument v) { String ret("{"); ret += ToString>>() diff --git a/octa/type_traits.h b/octa/type_traits.h index e240713..180a9da 100644 --- a/octa/type_traits.h +++ b/octa/type_traits.h @@ -55,15 +55,15 @@ template struct IntegralConstant { static constexpr T value = val; - typedef T Value; - typedef IntegralConstant Type; + using Value = T; + using Type = IntegralConstant; constexpr operator Value() const { return value; } constexpr Value operator()() const { return value; } }; -typedef IntegralConstant True; -typedef IntegralConstant False; +using True = IntegralConstant; +using False = IntegralConstant; template constexpr T IntegralConstant::value; @@ -343,7 +343,7 @@ struct HasVirtualDestructor: IntegralConstant &&>(v) - template struct Select2nd { typedef T Type; }; + template struct Select2nd { using Type = T; }; struct Any { Any(...); }; template typename Select2nd< @@ -482,7 +482,7 @@ template struct IsMoveAssignable: IsAssignable< /* is destructible */ namespace detail { - template struct IsDtibleApply { typedef int Type; }; + template struct IsDtibleApply { using Type = int; }; template struct IsDestructorWellformed { template static char test(typename IsDtibleApply< @@ -619,7 +619,7 @@ namespace detail { template::value || octa::IsFunction::value || octa::IsArray::value > struct IsConvertibleBase { - typedef typename octa::IsVoid::Type Type; + using Type = typename octa::IsVoid::Type; }; template @@ -632,7 +632,7 @@ namespace detail { template static octa::False test(...); - typedef decltype(test(0)) Type; + using Type = decltype(test(0)); }; } @@ -675,14 +675,14 @@ struct Rank: IntegralConstant::value + 1> {}; namespace detail { template - struct RemoveConstBase { typedef T Type; }; + struct RemoveConstBase { using Type = T; }; template - struct RemoveConstBase { typedef T Type; }; + struct RemoveConstBase { using Type = T; }; template - struct RemoveVolatileBase { typedef T Type; }; + struct RemoveVolatileBase { using Type = T; }; template - struct RemoveVolatileBase { typedef T Type; }; + struct RemoveVolatileBase { using Type = T; }; } template @@ -693,7 +693,7 @@ using RemoveVolatile = typename octa::detail::RemoveVolatileBase::Type; namespace detail { template struct RemoveCvBase { - typedef octa::RemoveVolatile> Type; + using Type = octa::RemoveVolatile>; }; } @@ -702,26 +702,26 @@ namespace detail { namespace detail { template::value || octa::IsFunction::value || octa::IsConst::value> - struct AddConstCore { typedef T Type; }; + struct AddConstCore { using Type = T; }; template struct AddConstCore { - typedef const T Type; + using Type = const T; }; template struct AddConstBase { - typedef typename AddConstCore::Type Type; + using Type = typename AddConstCore::Type; }; template::value || octa::IsFunction::value || octa::IsVolatile::value> - struct AddVolatileCore { typedef T Type; }; + struct AddVolatileCore { using Type = T; }; template struct AddVolatileCore { - typedef volatile T Type; + using Type = volatile T; }; template struct AddVolatileBase { - typedef typename AddVolatileCore::Type Type; + using Type = typename AddVolatileCore::Type; }; } @@ -731,7 +731,7 @@ using AddVolatile = typename octa::detail::AddVolatileBase::Type; namespace detail { template struct AddCvBase { - typedef octa::AddConst> Type; + using Type = octa::AddConst>; }; } @@ -742,26 +742,26 @@ using AddCv = typename octa::detail::AddCvBase::Type; namespace detail { template - struct RemoveReferenceBase { typedef T Type; }; + struct RemoveReferenceBase { using Type = T; }; template - struct RemoveReferenceBase { typedef T Type; }; + struct RemoveReferenceBase { using Type = T; }; template - struct RemoveReferenceBase { typedef T Type; }; + struct RemoveReferenceBase { using Type = T; }; } /* remove pointer */ namespace detail { template - struct RemovePointerBase { typedef T Type; }; + struct RemovePointerBase { using Type = T; }; template - struct RemovePointerBase { typedef T Type; }; + struct RemovePointerBase { using Type = T; }; template - struct RemovePointerBase { typedef T Type; }; + struct RemovePointerBase { using Type = T; }; template - struct RemovePointerBase { typedef T Type; }; + struct RemovePointerBase { using Type = T; }; template - struct RemovePointerBase { typedef T Type; }; + struct RemovePointerBase { using Type = T; }; } template @@ -771,7 +771,7 @@ using RemovePointer = typename octa::detail::RemovePointerBase::Type; namespace detail { template struct AddPointerBase { - typedef octa::RemoveReference *Type; + using Type = octa::RemoveReference *; }; } @@ -781,40 +781,40 @@ using AddPointer = typename octa::detail::AddPointerBase::Type; /* add lvalue reference */ namespace detail { - template struct AddLr { typedef T &Type; }; - template struct AddLr { typedef T &Type; }; - template struct AddLr { typedef T &Type; }; + template struct AddLr { using Type = T &; }; + template struct AddLr { using Type = T &; }; + template struct AddLr { using Type = T &; }; template<> struct AddLr { - typedef void Type; + using Type = void; }; template<> struct AddLr { - typedef const void Type; + using Type = const void; }; template<> struct AddLr { - typedef volatile void Type; + using Type = volatile void; }; template<> struct AddLr { - typedef const volatile void Type; + using Type = const volatile void; }; } /* add rvalue reference */ namespace detail { - template struct AddRr { typedef T &&Type; }; - template struct AddRr { typedef T &&Type; }; - template struct AddRr { typedef T &&Type; }; + template struct AddRr { using Type = T &&; }; + template struct AddRr { using Type = T &&; }; + template struct AddRr { using Type = T &&; }; template<> struct AddRr { - typedef void Type; + using Type = void; }; template<> struct AddRr { - typedef const void Type; + using Type = const void; }; template<> struct AddRr { - typedef volatile void Type; + using Type = volatile void; }; template<> struct AddRr { - typedef const volatile void Type; + using Type = const volatile void; }; } @@ -822,11 +822,11 @@ namespace detail { namespace detail { template - struct RemoveExtentBase { typedef T Type; }; + struct RemoveExtentBase { using Type = T; }; template - struct RemoveExtentBase { typedef T Type; }; + struct RemoveExtentBase { using Type = T; }; template - struct RemoveExtentBase { typedef T Type; }; + struct RemoveExtentBase { using Type = T; }; } template @@ -835,14 +835,14 @@ using RemoveExtent = typename octa::detail::RemoveExtentBase::Type; /* remove all extents */ namespace detail { - template struct RemoveAllExtentsBase { typedef T Type; }; + template struct RemoveAllExtentsBase { using Type = T; }; template struct RemoveAllExtentsBase { - typedef RemoveAllExtentsBase Type; + using Type = RemoveAllExtentsBase; }; template struct RemoveAllExtentsBase { - typedef RemoveAllExtentsBase Type; + using Type = RemoveAllExtentsBase; }; } @@ -854,8 +854,8 @@ namespace detail { namespace detail { template 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>>>> stypes; + using Stypes = TypeList>>>>; - typedef TypeList>>>> utypes; + using Utypes = TypeList>>>>; - template + template struct TypeFindFirst; template struct TypeFindFirst, N, true> { - typedef T Type; + using Type = T; }; template struct TypeFindFirst, N, false> { - typedef typename TypeFindFirst::Type Type; + using Type = typename TypeFindFirst::Type; }; template>::value, bool = octa::IsVolatile>::value > struct ApplyCv { - typedef U Type; + using Type = U; }; template struct ApplyCv { /* const */ - typedef const U Type; + using Type = const U; }; template struct ApplyCv { /* volatile */ - typedef volatile U Type; + using Type = volatile U; }; template struct ApplyCv { /* const volatile */ - typedef const volatile U Type; + using Type = const volatile U; }; template struct ApplyCv { /* const */ - typedef const U &Type; + using Type = const U &; }; template struct ApplyCv { /* volatile */ - typedef volatile U &Type; + using Type = volatile U &; }; template struct ApplyCv { /* const volatile */ - typedef const volatile U &Type; + using Type = const volatile U &; }; template::value || @@ -938,48 +938,48 @@ namespace detail { template struct MakeSigned { - typedef typename TypeFindFirst::Type Type; + using Type = typename TypeFindFirst::Type; }; template struct MakeUnsigned { - typedef typename TypeFindFirst::Type Type; + using Type = typename TypeFindFirst::Type; }; template<> struct MakeSigned {}; - template<> struct MakeSigned { typedef schar Type; }; - template<> struct MakeSigned { typedef schar Type; }; - template<> struct MakeSigned { typedef short Type; }; - template<> struct MakeSigned { typedef short Type; }; - template<> struct MakeSigned { typedef int Type; }; - template<> struct MakeSigned { typedef int Type; }; - template<> struct MakeSigned { typedef long Type; }; - template<> struct MakeSigned { typedef long Type; }; - template<> struct MakeSigned { typedef llong Type; }; - template<> struct MakeSigned { typedef llong Type; }; + template<> struct MakeSigned { using Type = schar; }; + template<> struct MakeSigned { using Type = schar; }; + template<> struct MakeSigned { using Type = short; }; + template<> struct MakeSigned { using Type = short; }; + template<> struct MakeSigned { using Type = int; }; + template<> struct MakeSigned { using Type = int; }; + template<> struct MakeSigned { using Type = long; }; + template<> struct MakeSigned { using Type = long; }; + template<> struct MakeSigned { using Type = llong; }; + template<> struct MakeSigned { using Type = llong; }; template<> struct MakeUnsigned {}; - template<> struct MakeUnsigned { typedef uchar Type; }; - template<> struct MakeUnsigned { typedef uchar Type; }; - template<> struct MakeUnsigned { typedef ushort Type; }; - template<> struct MakeUnsigned { typedef ushort Type; }; - template<> struct MakeUnsigned { typedef uint Type; }; - template<> struct MakeUnsigned { typedef uint Type; }; - template<> struct MakeUnsigned { typedef ulong Type; }; - template<> struct MakeUnsigned { typedef ulong Type; }; - template<> struct MakeUnsigned { typedef ullong Type; }; - template<> struct MakeUnsigned { typedef ullong Type; }; + template<> struct MakeUnsigned { using Type = uchar; }; + template<> struct MakeUnsigned { using Type = uchar; }; + template<> struct MakeUnsigned { using Type = ushort; }; + template<> struct MakeUnsigned { using Type = ushort; }; + template<> struct MakeUnsigned { using Type = uint; }; + template<> struct MakeUnsigned { using Type = uint; }; + template<> struct MakeUnsigned { using Type = ulong; }; + template<> struct MakeUnsigned { using Type = ulong; }; + template<> struct MakeUnsigned { using Type = ullong; }; + template<> struct MakeUnsigned { using Type = ullong; }; template struct MakeSignedBase { - typedef typename ApplyCv>::Type - >::Type Type; + >::Type; }; template struct MakeUnsignedBase { - typedef typename ApplyCv>::Type - >::Type Type; + >::Type; }; } /* namespace detail */ @@ -993,12 +993,12 @@ using MakeUnsigned = typename octa::detail::MakeUnsignedBase::Type; namespace detail { template struct ConditionalBase { - typedef T Type; + using Type = T; }; template struct ConditionalBase { - typedef U Type; + using Type = U; }; } @@ -1058,7 +1058,7 @@ using ResultOf = typename octa::detail::ResultOfBase::Type; namespace detail { template struct EnableIfBase {}; - template struct EnableIfBase { typedef T Type; }; + template struct EnableIfBase { using Type = T; }; } template @@ -1070,13 +1070,13 @@ namespace detail { template struct DecayBase { private: - typedef octa::RemoveReference U; + using U = octa::RemoveReference; public: - typedef octa::Conditional::value, + using Type = octa::Conditional::value, octa::RemoveExtent *, octa::Conditional::value, octa::AddPointer, octa::RemoveCv> - > Type; + >; }; } @@ -1089,18 +1089,19 @@ namespace detail { template struct CommonTypeBase; template struct CommonTypeBase { - typedef Decay Type; + using Type = Decay; }; template struct CommonTypeBase { - typedef Decay() - : octa::detail::declval_in())> Type; + using Type = Decay() + : octa::detail::declval_in())>; }; template struct CommonTypeBase { - typedef typename CommonTypeBase::Type, - V...>::Type Type; + using Type = typename CommonTypeBase< + typename CommonTypeBase::Type, V... + >::Type; }; } @@ -1166,7 +1167,7 @@ using AlignedUnion = typename octa::detail::AlignedUnionBase::Type; namespace detail { /* gotta wrap, in a struct otherwise clang ICEs... */ template struct UnderlyingTypeBase { - typedef __underlying_type(T) Type; + using Type = __underlying_type(T); }; } diff --git a/octa/types.h b/octa/types.h index 942e9a4..68eb942 100644 --- a/octa/types.h +++ b/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 } diff --git a/octa/utility.h b/octa/utility.h index fbf8212..e6b927c 100644 --- a/octa/utility.h +++ b/octa/utility.h @@ -143,17 +143,17 @@ template struct ReferenceWrapper; namespace detail { template struct MakePairRetBase { - typedef T Type; + using Type = T; }; template struct MakePairRetBase> { - typedef T &Type; + using Type = T &; }; template struct MakePairRet { - typedef typename octa::detail::MakePairRetBase>::Type Type; + using Type = typename octa::detail::MakePairRetBase>::Type; }; } /* namespace detail */ diff --git a/octa/vector.h b/octa/vector.h index 1f5fda8..7024e59 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -59,9 +59,9 @@ namespace detail { template> class Vector { - typedef octa::detail::VectorPair _vp_type; + using VecPair = octa::detail::VectorPair; - _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 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; + using ConstRange = PointerRange; + 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; }