From ff90009450bcdf1c64b416f5a208ecbd9ce6358b Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 3 Jun 2015 19:52:20 +0100 Subject: [PATCH] get rid of stupid Type suffixes (we already know it's a type from the name) --- octa/array.h | 22 ++--- octa/functional.h | 90 +++++++++--------- octa/memory.h | 222 ++++++++++++++++++++++----------------------- octa/range.h | 34 +++---- octa/string.h | 66 +++++++------- octa/type_traits.h | 6 +- octa/vector.h | 26 +++--- 7 files changed, 233 insertions(+), 233 deletions(-) diff --git a/octa/array.h b/octa/array.h index 106abc3..1c734ee 100644 --- a/octa/array.h +++ b/octa/array.h @@ -15,15 +15,15 @@ namespace octa { template struct Array { - typedef size_t SizeType; - typedef ptrdiff_t DiffType; - typedef _T ValType; - typedef _T &RefType; - typedef const _T &ConstRefType; - typedef _T *PtrType; - typedef const _T *ConstPtrType; - typedef PointerRange< _T> RangeType; - typedef PointerRange ConstRangeType; + 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; _T &operator[](size_t __i) { return __buf[__i]; } const _T &operator[](size_t __i) const { return __buf[__i]; } @@ -50,10 +50,10 @@ namespace octa { _T *data() { return __buf; } const _T *data() const { return __buf; } - RangeType each() { + Range each() { return octa::PointerRange<_T>(__buf, __buf + _N); } - ConstRangeType each() const { + ConstRange each() const { return octa::PointerRange(__buf, __buf + _N); } diff --git a/octa/functional.h b/octa/functional.h index dcbcfd7..fb01f12 100644 --- a/octa/functional.h +++ b/octa/functional.h @@ -19,9 +19,9 @@ namespace octa { _rettype operator()(const _T &__x, const _T &__y) const { \ return __x _op __y; \ } \ - typedef _T FirstArgType; \ - typedef _T SecondArgType; \ - typedef _rettype ResultType; \ + typedef _T FirstArgument; \ + typedef _T SecondArgument; \ + typedef _rettype Result; \ }; __OCTA_DEFINE_BINARY_OP(Less, <, bool) @@ -45,25 +45,25 @@ namespace octa { template struct LogicalNot { bool operator()(const _T &__x) const { return !__x; } - typedef _T ArgType; - typedef bool ResultType; + typedef _T Argument; + typedef bool Result; }; template struct Negate { bool operator()(const _T &__x) const { return -__x; } - typedef _T ArgType; - typedef _T ResultType; + typedef _T Argument; + typedef _T Result; }; template struct BinaryNegate { - typedef typename _T::FirstArgType FirstArgType; - typedef typename _T::SecondArgType SecondArgType; - typedef bool ResultType; + typedef typename _T::FirstArgument FirstArgument; + typedef typename _T::SecondArgument SecondArgument; + typedef bool Result; explicit BinaryNegate(const _T &__f): __fn(__f) {} - bool operator()(const FirstArgType &__x, - const SecondArgType &__y) { + bool operator()(const FirstArgument &__x, + const SecondArgument &__y) { return !__fn(__x, __y); } private: @@ -71,11 +71,11 @@ namespace octa { }; template struct UnaryNegate { - typedef typename _T::ArgType ArgType; - typedef bool ResultType; + typedef typename _T::Argument Argument; + typedef bool Result; explicit UnaryNegate(const _T &__f): __fn(__f) {} - bool operator()(const ArgType &__x) { + bool operator()(const Argument &__x) { return !__fn(__x); } private: @@ -95,8 +95,8 @@ namespace octa { template struct Hash; template struct __OctaHashBase { - typedef _T ArgType; - typedef size_t ResultType; + typedef _T Argument; + typedef size_t Result; size_t operator()(_T __v) const { return size_t(__v); @@ -132,8 +132,8 @@ namespace octa { struct __OctaScalarHash; template struct __OctaScalarHash<_T, 0> { - typedef _T ArgType; - typedef size_t ResultType; + typedef _T Argument; + typedef size_t Result; size_t operator()(_T __v) const { union { _T __v; size_t __h; } __u; @@ -144,8 +144,8 @@ namespace octa { }; template struct __OctaScalarHash<_T, 1> { - typedef _T ArgType; - typedef size_t ResultType; + typedef _T Argument; + typedef size_t Result; size_t operator()(_T __v) const { union { _T __v; size_t __h; } __u; @@ -155,8 +155,8 @@ namespace octa { }; template struct __OctaScalarHash<_T, 2> { - typedef _T ArgType; - typedef size_t ResultType; + typedef _T Argument; + typedef size_t Result; size_t operator()(_T __v) const { union { _T __v; struct { size_t __h1, __h2; }; } __u; @@ -166,8 +166,8 @@ namespace octa { }; template struct __OctaScalarHash<_T, 3> { - typedef _T ArgType; - typedef size_t ResultType; + typedef _T Argument; + typedef size_t Result; size_t operator()(_T __v) const { union { _T __v; struct { size_t __h1, __h2, __h3; }; } __u; @@ -177,8 +177,8 @@ namespace octa { }; template struct __OctaScalarHash<_T, 4> { - typedef _T ArgType; - typedef size_t ResultType; + typedef _T Argument; + typedef size_t Result; size_t operator()(_T __v) const { union { _T __v; struct { size_t __h1, __h2, __h3, __h4; }; } __u; @@ -226,8 +226,8 @@ namespace octa { }; template struct Hash<_T *> { - typedef _T *ArgType; - typedef size_t ResultType; + typedef _T *Argument; + typedef size_t Result; size_t operator()(_T *__v) const { union { _T *__v; size_t __h; } __u; @@ -280,25 +280,25 @@ namespace octa { template struct __OctaMemTypes; template struct __OctaMemTypes<_T, _R(_A...)> { - typedef _R ResultType; - typedef _T ArgType; + typedef _R Result; + typedef _T Argument; }; template struct __OctaMemTypes<_T, _R(_A)> { - typedef _R ResultType; - typedef _T FirstArgType; - typedef _A SecondArgType; + typedef _R Result; + typedef _T FirstArgument; + typedef _A SecondArgument; }; template struct __OctaMemTypes<_T, _R(_A...) const> { - typedef _R ResultType; - typedef const _T ArgType; + typedef _R Result; + typedef const _T Argument; }; template struct __OctaMemTypes<_T, _R(_A) const> { - typedef _R ResultType; - typedef const _T FirstArgType; - typedef _A SecondArgType; + typedef _R Result; + typedef const _T FirstArgument; + typedef _A SecondArgument; }; template @@ -469,20 +469,20 @@ namespace octa { template struct __OctaFunction { - typedef _R ResultType; + typedef _R Result; }; template struct __OctaFunction<_R, _T> { - typedef _R ResultType; - typedef _T ArgType; + typedef _R Result; + typedef _T Argument; }; template struct __OctaFunction<_R, _T, _U> { - typedef _R ResultType; - typedef _T FirstArgType; - typedef _U SecondArgType; + typedef _R Result; + typedef _T FirstArgument; + typedef _U SecondArgument; }; template diff --git a/octa/memory.h b/octa/memory.h index f6fa3ac..31527a4 100644 --- a/octa/memory.h +++ b/octa/memory.h @@ -23,25 +23,25 @@ namespace octa { /* pointer traits */ template - struct __OctaHasElementType { + struct __OctaHasElement { template static int __test(...); template - static char __test(typename _U::ElementType * = 0); + static char __test(typename _U::Element * = 0); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; - template::value> + template::value> struct __OctaPtrTraitsElementType; template struct __OctaPtrTraitsElementType<_T, true> { - typedef typename _T::ElementType Type; + typedef typename _T::Element Type; }; template class _T, typename _U, typename ..._A> struct __OctaPtrTraitsElementType<_T<_U, _A...>, true> { - typedef typename _T<_U, _A...>::ElementType Type; + typedef typename _T<_U, _A...>::Element Type; }; template class _T, typename _U, typename ..._A> @@ -50,22 +50,22 @@ namespace octa { }; template - struct __OctaHasDiffType { + struct __OctaHasDifference { template static int __test(...); template - static char __test(typename _U::DiffType * = 0); + static char __test(typename _U::Difference * = 0); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; - template::value> - struct __OctaPtrTraitsDiffType { + template::value> + struct __OctaPtrTraitsDifferenceType { typedef ptrdiff_t Type; }; - template struct __OctaPtrTraitsDiffType<_T, true> { - typedef typename _T::DiffType Type; + template struct __OctaPtrTraitsDifferenceType<_T, true> { + typedef typename _T::Difference Type; }; template @@ -108,7 +108,7 @@ namespace octa { }; template - using PtrType = typename __OctaPtrTraitsPointer<_T>::Type; + using Pointer = typename __OctaPtrTraitsPointer<_T>::Type; template struct __OctaPtrTraitsElement { @@ -125,13 +125,13 @@ namespace octa { template struct __OctaPtrTraitsDifference { - typedef typename __OctaPtrTraitsDiffType<_T>::Type Type; + typedef typename __OctaPtrTraitsDifferenceType<_T>::Type Type; }; template struct __OctaPtrTraitsDifference<_T *> { - typedef ptrdiff_t DiffType; + typedef ptrdiff_t Type; }; template @@ -248,30 +248,30 @@ namespace octa { template static int __octa_ptr_test(...); template - static char __octa_ptr_test(typename _T::PtrType * = 0); + static char __octa_ptr_test(typename _T::Pointer * = 0); template struct __OctaHasPtr: octa::IntegralConstant(0)) == 1) > {}; template::value> - struct __OctaPtrTypeBase { - typedef typename _D::PtrType Type; + struct __OctaPointerBase { + typedef typename _D::Pointer Type; }; - template struct __OctaPtrTypeBase<_T, _D, false> { + template struct __OctaPointerBase<_T, _D, false> { typedef _T *Type; }; - template struct __OctaPtrType { - typedef typename __OctaPtrTypeBase<_T, octa::RemoveReference<_D>>::Type Type; + template struct __OctaPointer { + typedef typename __OctaPointerBase<_T, octa::RemoveReference<_D>>::Type Type; }; template> struct Box { - typedef _T ElementType; - typedef _D DeleterType; - typedef typename __OctaPtrType<_T, _D>::Type PtrType; + typedef _T Element; + typedef _D Deleter; + typedef typename __OctaPointer<_T, _D>::Type Pointer; private: struct __OctaNat { int __x; }; @@ -289,16 +289,16 @@ namespace octa { "Box constructed with null fptr deleter"); } - explicit Box(PtrType __p): __stor(__p, _D()) { + explicit Box(Pointer __p): __stor(__p, _D()) { static_assert(!octa::IsPointer<_D>::value, "Box constructed with null fptr deleter"); } - Box(PtrType __p, octa::Conditional::value, + Box(Pointer __p, octa::Conditional::value, _D, octa::AddLvalueReference > __d): __stor(__p, __d) {} - Box(PtrType __p, octa::RemoveReference<_D> &&__d): + Box(Pointer __p, octa::RemoveReference<_D> &&__d): __stor(__p, octa::move(__d)) { static_assert(!octa::IsReference<_D>::value, "rvalue deleter cannot be a ref"); @@ -309,7 +309,7 @@ namespace octa { template Box(Box<_TT, _DD> &&__u, octa::EnableIf::value - && octa::IsConvertible::PtrType, PtrType>::value + && octa::IsConvertible::Pointer, Pointer>::value && octa::IsConvertible<_DD, _D>::value && (!octa::IsReference<_D>::value || octa::IsSame<_D, _DD>::value) > = __OctaNat()): __stor(__u.release(), octa::forward<_DD>(__u.get_deleter())) {} @@ -322,7 +322,7 @@ namespace octa { template EnableIf::value - && octa::IsConvertible::PtrType, PtrType>::value + && octa::IsConvertible::Pointer, Pointer>::value && octa::IsAssignable<_D &, _DD &&>::value, Box & > operator=(Box<_TT, _DD> &&__u) { @@ -339,25 +339,25 @@ namespace octa { ~Box() { reset(); } octa::AddLvalueReference<_T> operator*() const { return *__stor.__ptr; } - PtrType operator->() const { return __stor.__ptr; } + Pointer operator->() const { return __stor.__ptr; } explicit operator bool() const { return __stor.__ptr != nullptr; } - PtrType get() const { return __stor.__ptr; } + Pointer get() const { return __stor.__ptr; } _D_ref get_deleter() { return __stor.get_deleter(); } _D_cref get_deleter() const { return __stor.get_deleter(); } - PtrType release() { - PtrType __p = __stor.__ptr; + Pointer release() { + Pointer __p = __stor.__ptr; __stor.__ptr = nullptr; return __p; } - void reset(PtrType __p = nullptr) { - PtrType __tmp = __stor.__ptr; + void reset(Pointer __p = nullptr) { + Pointer __tmp = __stor.__ptr; __stor.__ptr = __p; if (__tmp) __stor.get_deleter()(__tmp); } @@ -379,7 +379,7 @@ namespace octa { struct __OctaSameOrLessCvQualifiedBase<_T, _U, false>: octa::False {}; template::value - || octa::IsSame<_T, _U>::value || __OctaHasElementType<_T>::value + || octa::IsSame<_T, _U>::value || __OctaHasElement<_T>::value > struct __OctaSameOrLessCvQualified: __OctaSameOrLessCvQualifiedBase<_T, _U> {}; template @@ -387,9 +387,9 @@ namespace octa { template struct Box<_T[], _D> { - typedef _T ElementType; - typedef _D DeleterType; - typedef typename __OctaPtrType<_T, _D>::Type PtrType; + typedef _T Element; + typedef _D Deleter; + typedef typename __OctaPointer<_T, _D>::Type Pointer; private: struct __OctaNat { int __x; }; @@ -408,7 +408,7 @@ namespace octa { } template explicit Box(_U __p, octa::EnableIf< - __OctaSameOrLessCvQualified<_U, PtrType>::value, __OctaNat + __OctaSameOrLessCvQualified<_U, Pointer>::value, __OctaNat > = __OctaNat()): __stor(__p, _D()) { static_assert(!octa::IsPointer<_D>::value, "Box constructed with null fptr deleter"); @@ -417,7 +417,7 @@ namespace octa { template Box(_U __p, octa::Conditional< octa::IsReference<_D>::value, _D, AddLvalueReference - > __d, octa::EnableIf<__OctaSameOrLessCvQualified<_U, PtrType>::value, + > __d, octa::EnableIf<__OctaSameOrLessCvQualified<_U, Pointer>::value, __OctaNat> = __OctaNat()): __stor(__p, __d) {} Box(nullptr_t, octa::Conditional::value, @@ -426,7 +426,7 @@ namespace octa { template Box(_U __p, octa::RemoveReference<_D> &&__d, octa::EnableIf< - __OctaSameOrLessCvQualified<_U, PtrType>::value, __OctaNat + __OctaSameOrLessCvQualified<_U, Pointer>::value, __OctaNat > = __OctaNat()): __stor(__p, octa::move(__d)) { static_assert(!octa::IsReference<_D>::value, "rvalue deleter cannot be a ref"); @@ -443,8 +443,8 @@ namespace octa { template Box(Box<_TT, _DD> &&__u, EnableIf::value - && __OctaSameOrLessCvQualified::PtrType, - PtrType>::value + && __OctaSameOrLessCvQualified::Pointer, + Pointer>::value && octa::IsConvertible<_DD, _D>::value && (!octa::IsReference<_D>::value || octa::IsSame<_D, _DD>::value)> = __OctaNat() @@ -458,8 +458,8 @@ namespace octa { template EnableIf::value - && __OctaSameOrLessCvQualified::PtrType, - PtrType>::value + && __OctaSameOrLessCvQualified::Pointer, + Pointer>::value && IsAssignable<_D &, _DD &&>::value, Box & > operator=(Box<_TT, _DD> &&__u) { @@ -483,27 +483,27 @@ namespace octa { return __stor.__ptr != nullptr; } - PtrType get() const { return __stor.__ptr; } + Pointer get() const { return __stor.__ptr; } _D_ref get_deleter() { return __stor.get_deleter(); } _D_cref get_deleter() const { return __stor.get_deleter(); } - PtrType release() { - PtrType __p = __stor.__ptr; + Pointer release() { + Pointer __p = __stor.__ptr; __stor.__ptr = nullptr; return __p; } template EnableIf< - __OctaSameOrLessCvQualified<_U, PtrType>::value, void + __OctaSameOrLessCvQualified<_U, Pointer>::value, void > reset(_U __p) { - PtrType __tmp = __stor.__ptr; + Pointer __tmp = __stor.__ptr; __stor.__ptr = __p; if (__tmp) __stor.get_deleter()(__tmp); } void reset(nullptr_t) { - PtrType __tmp = __stor.__ptr; + Pointer __tmp = __stor.__ptr; __stor.__ptr = nullptr; if (__tmp) __stor.get_deleter()(__tmp); } @@ -550,84 +550,84 @@ namespace octa { template struct Allocator; template<> struct Allocator { - typedef void ValType; - typedef void *PtrType; - typedef const void *ConstPtrType; + typedef void Value; + typedef void *Pointer; + typedef const void *ConstPointer; template using Rebind = Allocator<_U>; }; template<> struct Allocator { - typedef const void ValType; - typedef const void *PtrType; - typedef const void *ConstPtrType; + typedef const void Value; + typedef const void *Pointer; + typedef const void *ConstPointer; template using Rebind = Allocator<_U>; }; template struct Allocator { - typedef size_t SizeType; - typedef ptrdiff_t DiffType; - typedef _T ValType; - typedef _T &RefType; - typedef const _T &ConstRefType; - typedef _T *PtrType; - typedef const _T *ConstPtrType; + 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; template using Rebind = Allocator<_U>; - PtrType address(RefType __v) const { + Pointer address(Reference __v) const { return address_of(__v); }; - ConstPtrType address(ConstRefType __v) const { + ConstPointer address(ConstReference __v) const { return address_of(__v); }; - SizeType max_size() const { return SizeType(~0) / sizeof(_T); } + Size max_size() const { return Size(~0) / sizeof(_T); } - PtrType allocate(SizeType __n, Allocator::ConstPtrType = nullptr) { - return (PtrType) ::new uchar[__n * sizeof(_T)]; + Pointer allocate(Size __n, Allocator::ConstPointer = nullptr) { + return (Pointer) ::new uchar[__n * sizeof(_T)]; } - void deallocate(PtrType __p, SizeType) { ::delete[] (uchar *) __p; } + void deallocate(Pointer __p, Size) { ::delete[] (uchar *) __p; } template void construct(_U *__p, _A &&...__args) { ::new((void *)__p) _U(octa::forward<_A>(__args)...); } - void destroy(PtrType __p) { __p->~_T(); } + void destroy(Pointer __p) { __p->~_T(); } }; template struct Allocator { - typedef size_t SizeType; - typedef ptrdiff_t DiffType; - typedef const _T ValType; - typedef const _T &RefType; - typedef const _T &ConstRefType; - typedef const _T *PtrType; - typedef const _T *ConstPtrType; + 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; template using Rebind = Allocator<_U>; - ConstPtrType address(ConstRefType __v) const { + ConstPointer address(ConstReference __v) const { return address_of(__v); }; - SizeType max_size() const { return SizeType(~0) / sizeof(_T); } + Size max_size() const { return Size(~0) / sizeof(_T); } - PtrType allocate(SizeType __n, Allocator::ConstPtrType = nullptr) { - return (PtrType) ::new uchar[__n * sizeof(_T)]; + Pointer allocate(Size __n, Allocator::ConstPointer = nullptr) { + return (Pointer) ::new uchar[__n * sizeof(_T)]; } - void deallocate(PtrType __p, SizeType) { ::delete[] (uchar *) __p; } + void deallocate(Pointer __p, Size) { ::delete[] (uchar *) __p; } template void construct(_U *__p, _A &&...__args) { ::new((void *)__p) _U(octa::forward<_A>(__args)...); } - void destroy(PtrType __p) { __p->~_T(); } + void destroy(Pointer __p) { __p->~_T(); } }; template @@ -645,73 +645,73 @@ namespace octa { template struct __OctaConstPtrTest { template static char __test( - typename _U::ConstPtrType * = 0); + typename _U::ConstPointer * = 0); template static int __test(...); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; template::value> - struct __OctaConstPtrType { - typedef typename _A::ConstPtrType Type; + struct __OctaConstPointer { + typedef typename _A::ConstPointer Type; }; template - struct __OctaConstPtrType<_T, _P, _A, false> { + struct __OctaConstPointer<_T, _P, _A, false> { typedef PointerRebind<_P, const _T> Type; }; template struct __OctaVoidPtrTest { template static char __test( - typename _U::VoidPtrType * = 0); + typename _U::VoidPointer * = 0); template static int __test(...); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; template::value> - struct __OctaVoidPtrType { - typedef typename _A::VoidPtrType Type; + struct __OctaVoidPointer { + typedef typename _A::VoidPointer Type; }; template - struct __OctaVoidPtrType<_P, _A, false> { + struct __OctaVoidPointer<_P, _A, false> { typedef PointerRebind<_P, void> Type; }; template struct __OctaConstVoidPtrTest { template static char __test( - typename _U::ConstVoidPtrType * = 0); + typename _U::ConstVoidPointer * = 0); template static int __test(...); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; template::value> - struct __OctaConstVoidPtrType { - typedef typename _A::ConstVoidPtrType Type; + struct __OctaConstVoidPointer { + typedef typename _A::ConstVoidPointer Type; }; template - struct __OctaConstVoidPtrType<_P, _A, false> { + struct __OctaConstVoidPointer<_P, _A, false> { typedef PointerRebind<_P, const void> Type; }; template struct __OctaSizeTest { - template static char __test(typename _U::SizeType * = 0); + template static char __test(typename _U::Size * = 0); template static int __test(...); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; template::value> - struct __OctaSizeType { + struct __OctaSize { typedef octa::MakeUnsigned<_D> Type; }; template - struct __OctaSizeType<_A, _D, true> { - typedef typename _A::SizeType Type; + struct __OctaSize<_A, _D, true> { + typedef typename _A::Size Type; }; /* allocator type traits */ @@ -720,25 +720,25 @@ namespace octa { using AllocatorType = _A; template - using AllocatorValue = typename AllocatorType<_A>::ValType; + using AllocatorValue = typename AllocatorType<_A>::Value; template - using AllocatorPointer = typename __OctaPtrType< + using AllocatorPointer = typename __OctaPointer< AllocatorValue<_A>, AllocatorType <_A> >::Type; template - using AllocatorConstPointer = typename __OctaConstPtrType< + using AllocatorConstPointer = typename __OctaConstPointer< AllocatorValue<_A>, AllocatorPointer<_A>, AllocatorType<_A> >::Type; template - using AllocatorVoidPointer = typename __OctaVoidPtrType< + using AllocatorVoidPointer = typename __OctaVoidPointer< AllocatorPointer<_A>, AllocatorType<_A> >::Type; template - using AllocatorConstVoidPointer = typename __OctaConstVoidPtrType< + using AllocatorConstVoidPointer = typename __OctaConstVoidPointer< AllocatorPointer<_A>, AllocatorType<_A> >::Type; @@ -746,30 +746,30 @@ namespace octa { template struct __OctaDiffTest { - template static char __test(typename _U::DiffType * = 0); + template static char __test(typename _U::Difference * = 0); template static int __test(...); static constexpr bool value = (sizeof(__test<_T>(0)) == 1); }; template::value> - struct __OctaAllocDiffType { + struct __OctaAllocDifference { typedef PointerDifference<_P> Type; }; template - struct __OctaAllocDiffType<_A, _P, true> { - typedef typename _A::DiffType Type; + struct __OctaAllocDifference<_A, _P, true> { + typedef typename _A::Difference Type; }; template - using AllocatorDifference = typename __OctaAllocDiffType< + using AllocatorDifference = typename __OctaAllocDifference< _A, AllocatorPointer<_A> >::Type; /* allocator size */ template - using AllocatorSize = typename __OctaSizeType< + using AllocatorSize = typename __OctaSize< _A, AllocatorDifference<_A> >::Type; diff --git a/octa/range.h b/octa/range.h index 136b2e9..eb76979 100644 --- a/octa/range.h +++ b/octa/range.h @@ -35,10 +35,10 @@ namespace octa { using Range##_Name = typename __OctaRange##_Name<_T>::Type; __OCTA_RANGE_TRAIT(Category, Category) - __OCTA_RANGE_TRAIT(Size, SizeType) - __OCTA_RANGE_TRAIT(Value, ValType) - __OCTA_RANGE_TRAIT(Reference, RefType) - __OCTA_RANGE_TRAIT(Difference, DiffType) + __OCTA_RANGE_TRAIT(Size, Size) + __OCTA_RANGE_TRAIT(Value, Value) + __OCTA_RANGE_TRAIT(Reference, Reference) + __OCTA_RANGE_TRAIT(Difference, Difference) #undef __OCTA_RANGE_TRAIT @@ -139,7 +139,7 @@ namespace octa { private: _T __range; public: - typedef _T RangeType; + typedef _T Range; RangeHalf(): __range() {} RangeHalf(const _T &__range): __range(__range) {} @@ -279,10 +279,10 @@ namespace octa { typename _S = size_t, typename _D = ptrdiff_t > struct InputRange { typedef _C Category; - typedef _S SizeType; - typedef _D DiffType; - typedef _V ValType; - typedef _R RefType; + typedef _S Size; + typedef _D Difference; + typedef _V Value; + typedef _R Reference; __OctaRangeIterator<_B> begin() const { return __OctaRangeIterator<_B>((const _B &)*this); @@ -291,19 +291,19 @@ namespace octa { return __OctaRangeIterator<_B>(); } - SizeType pop_front_n(SizeType __n) { + Size pop_front_n(Size __n) { return __octa_pop_front_n<_B>(*((_B *)this), __n); } - SizeType pop_back_n(SizeType __n) { + Size pop_back_n(Size __n) { return __octa_pop_back_n<_B>(*((_B *)this), __n); } - SizeType push_front_n(SizeType __n) { + Size push_front_n(Size __n) { return __octa_push_front_n<_B>(*((_B *)this), __n); } - SizeType push_back_n(SizeType __n) { + Size push_back_n(Size __n) { return __octa_push_back_n<_B>(*((_B *)this), __n); } @@ -320,10 +320,10 @@ namespace octa { typename _D = ptrdiff_t > struct OutputRange { typedef OutputRangeTag Category; - typedef _S SizeType; - typedef _D DiffType; - typedef _V ValType; - typedef _R RefType; + typedef _S Size; + typedef _D Difference; + typedef _V Value; + typedef _R Reference; }; template diff --git a/octa/string.h b/octa/string.h index b6e56e9..3eac95f 100644 --- a/octa/string.h +++ b/octa/string.h @@ -25,15 +25,15 @@ namespace octa { } public: - typedef size_t SizeType; - typedef ptrdiff_t DiffType; - typedef _T ValType; - typedef _T &RefType; - typedef const _T &ConstRefType; - typedef _T *PtrType; - typedef const _T *ConstPtrType; - typedef PointerRange< _T> RangeType; - typedef PointerRange ConstRangeType; + 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; StringBase(): __buf(1, '\0') {} @@ -47,7 +47,7 @@ namespace octa { } /* TODO: traits for utf-16/utf-32 string lengths, for now assume char */ - StringBase(const _T *__v): __buf(ConstRangeType(__v, strlen(__v) + 1)) {} + StringBase(const _T *__v): __buf(ConstRange(__v, strlen(__v) + 1)) {} template StringBase(_R __range): __buf(__range) { __terminate(); @@ -64,7 +64,7 @@ namespace octa { return *this; } StringBase<_T> &operator=(const _T *__v) { - __buf = ConstRangeType(__v, strlen(__v) + 1); + __buf = ConstRange(__v, strlen(__v) + 1); return *this; } @@ -124,7 +124,7 @@ namespace octa { StringBase<_T> &append(const _T *__s) { __buf.pop(); - __buf.insert_range(__buf.size(), ConstRangeType(__s, + __buf.insert_range(__buf.size(), ConstRange(__s, strlen(__s) + 1)); return *this; } @@ -157,11 +157,11 @@ namespace octa { return *this; } - RangeType each() { - return RangeType(__buf.data(), size()); + Range each() { + return Range(__buf.data(), size()); } - ConstRangeType each() const { - return ConstRangeType(__buf.data(), size()); + ConstRange each() const { + return ConstRange(__buf.data(), size()); } void swap(StringBase &__v) { @@ -225,8 +225,8 @@ namespace octa { }; template struct ToString { - typedef _T ArgType; - typedef String ResultType; + typedef _T Argument; + typedef String Result; template static String __octa_to_str(const _U &__v, @@ -281,16 +281,16 @@ namespace octa { } template<> struct ToString { - typedef bool ArgType; - typedef String ResultType; + typedef bool Argument; + typedef String Result; String operator()(bool __b) { return __b ? "true" : "false"; } }; template<> struct ToString { - typedef char ArgType; - typedef String ResultType; + typedef char Argument; + typedef String Result; String operator()(char __c) { String __ret; __ret.push(__c); @@ -300,8 +300,8 @@ namespace octa { #define __OCTA_TOSTR_NUM(_T, __fmt) \ template<> struct ToString<_T> { \ - typedef _T ArgType; \ - typedef String ResultType; \ + typedef _T Argument; \ + typedef String Result; \ String operator()(_T __v) { \ String __ret; \ __octa_str_printf((octa::Vector *)&__ret, __fmt, __v); \ @@ -323,9 +323,9 @@ namespace octa { #undef __OCTA_TOSTR_NUM template struct ToString<_T *> { - typedef _T *ArgType; - typedef String ResultType; - String operator()(ArgType __v) { + typedef _T *Argument; + typedef String Result; + String operator()(Argument __v) { String __ret; __octa_str_printf((octa::Vector *)&__ret, "%p", __v); return octa::move(__ret); @@ -333,17 +333,17 @@ namespace octa { }; template<> struct ToString { - typedef const String &ArgType; - typedef String ResultType; - String operator()(ArgType __s) { + typedef const String &Argument; + typedef String Result; + String operator()(Argument __s) { return __s; } }; template struct ToString> { - typedef const octa::Pair<_T, _U> &ArgType; - typedef String ResultType; - String operator()(ArgType __v) { + typedef const octa::Pair<_T, _U> &Argument; + typedef String Result; + String operator()(Argument __v) { String __ret("{"); __ret += ToString>>() (__v.first); diff --git a/octa/type_traits.h b/octa/type_traits.h index 7a1dc0f..4c06c82 100644 --- a/octa/type_traits.h +++ b/octa/type_traits.h @@ -51,11 +51,11 @@ namespace octa { struct IntegralConstant { static constexpr _T value = __val; - typedef _T ValType; + typedef _T Value; typedef IntegralConstant<_T, __val> Type; - constexpr operator ValType() const { return value; } - constexpr ValType operator()() const { return value; } + constexpr operator Value() const { return value; } + constexpr Value operator()() const { return value; } }; typedef IntegralConstant True; diff --git a/octa/vector.h b/octa/vector.h index 26d8ffc..e3f0a40 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -59,15 +59,15 @@ namespace octa { public: enum { MIN_SIZE = 8 }; - typedef size_t SizeType; - typedef ptrdiff_t DiffType; - typedef _T ValType; - typedef _T &RefType; - typedef const _T &ConstRefType; - typedef _T *PtrType; - typedef const _T *ConstPtrType; - typedef PointerRange< _T> RangeType; - typedef PointerRange ConstRangeType; + 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; Vector(): __buf(nullptr), __len(0), __cap(0) {} @@ -297,11 +297,11 @@ namespace octa { return insert_range(__idx, octa::each(__il)); } - RangeType each() { - return RangeType(__buf, __buf + __len); + Range each() { + return Range(__buf, __buf + __len); } - ConstRangeType each() const { - return ConstRangeType(__buf, __buf + __len); + ConstRange each() const { + return ConstRange(__buf, __buf + __len); } void swap(Vector &__v) {