get rid of stupid Type suffixes (we already know it's a type from the name)

master
Daniel Kolesa 2015-06-03 19:52:20 +01:00
parent 749434f98c
commit ff90009450
7 changed files with 233 additions and 233 deletions

View File

@ -15,15 +15,15 @@
namespace octa { namespace octa {
template<typename _T, size_t _N> template<typename _T, size_t _N>
struct Array { struct Array {
typedef size_t SizeType; typedef size_t Size;
typedef ptrdiff_t DiffType; typedef ptrdiff_t Difference;
typedef _T ValType; typedef _T Value;
typedef _T &RefType; typedef _T &Reference;
typedef const _T &ConstRefType; typedef const _T &ConstReference;
typedef _T *PtrType; typedef _T *Pointer;
typedef const _T *ConstPtrType; typedef const _T *ConstPointer;
typedef PointerRange< _T> RangeType; typedef PointerRange< _T> Range;
typedef PointerRange<const _T> ConstRangeType; typedef PointerRange<const _T> ConstRange;
_T &operator[](size_t __i) { return __buf[__i]; } _T &operator[](size_t __i) { return __buf[__i]; }
const _T &operator[](size_t __i) const { return __buf[__i]; } const _T &operator[](size_t __i) const { return __buf[__i]; }
@ -50,10 +50,10 @@ namespace octa {
_T *data() { return __buf; } _T *data() { return __buf; }
const _T *data() const { return __buf; } const _T *data() const { return __buf; }
RangeType each() { Range each() {
return octa::PointerRange<_T>(__buf, __buf + _N); return octa::PointerRange<_T>(__buf, __buf + _N);
} }
ConstRangeType each() const { ConstRange each() const {
return octa::PointerRange<const _T>(__buf, __buf + _N); return octa::PointerRange<const _T>(__buf, __buf + _N);
} }

View File

@ -19,9 +19,9 @@ namespace octa {
_rettype operator()(const _T &__x, const _T &__y) const { \ _rettype operator()(const _T &__x, const _T &__y) const { \
return __x _op __y; \ return __x _op __y; \
} \ } \
typedef _T FirstArgType; \ typedef _T FirstArgument; \
typedef _T SecondArgType; \ typedef _T SecondArgument; \
typedef _rettype ResultType; \ typedef _rettype Result; \
}; };
__OCTA_DEFINE_BINARY_OP(Less, <, bool) __OCTA_DEFINE_BINARY_OP(Less, <, bool)
@ -45,25 +45,25 @@ namespace octa {
template<typename _T> struct LogicalNot { template<typename _T> struct LogicalNot {
bool operator()(const _T &__x) const { return !__x; } bool operator()(const _T &__x) const { return !__x; }
typedef _T ArgType; typedef _T Argument;
typedef bool ResultType; typedef bool Result;
}; };
template<typename _T> struct Negate { template<typename _T> struct Negate {
bool operator()(const _T &__x) const { return -__x; } bool operator()(const _T &__x) const { return -__x; }
typedef _T ArgType; typedef _T Argument;
typedef _T ResultType; typedef _T Result;
}; };
template<typename _T> struct BinaryNegate { template<typename _T> struct BinaryNegate {
typedef typename _T::FirstArgType FirstArgType; typedef typename _T::FirstArgument FirstArgument;
typedef typename _T::SecondArgType SecondArgType; typedef typename _T::SecondArgument SecondArgument;
typedef bool ResultType; typedef bool Result;
explicit BinaryNegate(const _T &__f): __fn(__f) {} explicit BinaryNegate(const _T &__f): __fn(__f) {}
bool operator()(const FirstArgType &__x, bool operator()(const FirstArgument &__x,
const SecondArgType &__y) { const SecondArgument &__y) {
return !__fn(__x, __y); return !__fn(__x, __y);
} }
private: private:
@ -71,11 +71,11 @@ namespace octa {
}; };
template<typename _T> struct UnaryNegate { template<typename _T> struct UnaryNegate {
typedef typename _T::ArgType ArgType; typedef typename _T::Argument Argument;
typedef bool ResultType; typedef bool Result;
explicit UnaryNegate(const _T &__f): __fn(__f) {} explicit UnaryNegate(const _T &__f): __fn(__f) {}
bool operator()(const ArgType &__x) { bool operator()(const Argument &__x) {
return !__fn(__x); return !__fn(__x);
} }
private: private:
@ -95,8 +95,8 @@ namespace octa {
template<typename _T> struct Hash; template<typename _T> struct Hash;
template<typename _T> struct __OctaHashBase { template<typename _T> struct __OctaHashBase {
typedef _T ArgType; typedef _T Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T __v) const { size_t operator()(_T __v) const {
return size_t(__v); return size_t(__v);
@ -132,8 +132,8 @@ namespace octa {
struct __OctaScalarHash; struct __OctaScalarHash;
template<typename _T> struct __OctaScalarHash<_T, 0> { template<typename _T> struct __OctaScalarHash<_T, 0> {
typedef _T ArgType; typedef _T Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T __v) const { size_t operator()(_T __v) const {
union { _T __v; size_t __h; } __u; union { _T __v; size_t __h; } __u;
@ -144,8 +144,8 @@ namespace octa {
}; };
template<typename _T> struct __OctaScalarHash<_T, 1> { template<typename _T> struct __OctaScalarHash<_T, 1> {
typedef _T ArgType; typedef _T Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T __v) const { size_t operator()(_T __v) const {
union { _T __v; size_t __h; } __u; union { _T __v; size_t __h; } __u;
@ -155,8 +155,8 @@ namespace octa {
}; };
template<typename _T> struct __OctaScalarHash<_T, 2> { template<typename _T> struct __OctaScalarHash<_T, 2> {
typedef _T ArgType; typedef _T Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T __v) const { size_t operator()(_T __v) const {
union { _T __v; struct { size_t __h1, __h2; }; } __u; union { _T __v; struct { size_t __h1, __h2; }; } __u;
@ -166,8 +166,8 @@ namespace octa {
}; };
template<typename _T> struct __OctaScalarHash<_T, 3> { template<typename _T> struct __OctaScalarHash<_T, 3> {
typedef _T ArgType; typedef _T Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T __v) const { size_t operator()(_T __v) const {
union { _T __v; struct { size_t __h1, __h2, __h3; }; } __u; union { _T __v; struct { size_t __h1, __h2, __h3; }; } __u;
@ -177,8 +177,8 @@ namespace octa {
}; };
template<typename _T> struct __OctaScalarHash<_T, 4> { template<typename _T> struct __OctaScalarHash<_T, 4> {
typedef _T ArgType; typedef _T Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T __v) const { size_t operator()(_T __v) const {
union { _T __v; struct { size_t __h1, __h2, __h3, __h4; }; } __u; union { _T __v; struct { size_t __h1, __h2, __h3, __h4; }; } __u;
@ -226,8 +226,8 @@ namespace octa {
}; };
template<typename _T> struct Hash<_T *> { template<typename _T> struct Hash<_T *> {
typedef _T *ArgType; typedef _T *Argument;
typedef size_t ResultType; typedef size_t Result;
size_t operator()(_T *__v) const { size_t operator()(_T *__v) const {
union { _T *__v; size_t __h; } __u; union { _T *__v; size_t __h; } __u;
@ -280,25 +280,25 @@ namespace octa {
template<typename, typename> struct __OctaMemTypes; template<typename, typename> struct __OctaMemTypes;
template<typename _T, typename _R, typename ..._A> template<typename _T, typename _R, typename ..._A>
struct __OctaMemTypes<_T, _R(_A...)> { struct __OctaMemTypes<_T, _R(_A...)> {
typedef _R ResultType; typedef _R Result;
typedef _T ArgType; typedef _T Argument;
}; };
template<typename _T, typename _R, typename _A> template<typename _T, typename _R, typename _A>
struct __OctaMemTypes<_T, _R(_A)> { struct __OctaMemTypes<_T, _R(_A)> {
typedef _R ResultType; typedef _R Result;
typedef _T FirstArgType; typedef _T FirstArgument;
typedef _A SecondArgType; typedef _A SecondArgument;
}; };
template<typename _T, typename _R, typename ..._A> template<typename _T, typename _R, typename ..._A>
struct __OctaMemTypes<_T, _R(_A...) const> { struct __OctaMemTypes<_T, _R(_A...) const> {
typedef _R ResultType; typedef _R Result;
typedef const _T ArgType; typedef const _T Argument;
}; };
template<typename _T, typename _R, typename _A> template<typename _T, typename _R, typename _A>
struct __OctaMemTypes<_T, _R(_A) const> { struct __OctaMemTypes<_T, _R(_A) const> {
typedef _R ResultType; typedef _R Result;
typedef const _T FirstArgType; typedef const _T FirstArgument;
typedef _A SecondArgType; typedef _A SecondArgument;
}; };
template<typename _R, typename _T> template<typename _R, typename _T>
@ -469,20 +469,20 @@ namespace octa {
template<typename _R, typename...> template<typename _R, typename...>
struct __OctaFunction { struct __OctaFunction {
typedef _R ResultType; typedef _R Result;
}; };
template<typename _R, typename _T> template<typename _R, typename _T>
struct __OctaFunction<_R, _T> { struct __OctaFunction<_R, _T> {
typedef _R ResultType; typedef _R Result;
typedef _T ArgType; typedef _T Argument;
}; };
template<typename _R, typename _T, typename _U> template<typename _R, typename _T, typename _U>
struct __OctaFunction<_R, _T, _U> { struct __OctaFunction<_R, _T, _U> {
typedef _R ResultType; typedef _R Result;
typedef _T FirstArgType; typedef _T FirstArgument;
typedef _U SecondArgType; typedef _U SecondArgument;
}; };
template<typename, typename> template<typename, typename>

View File

@ -23,25 +23,25 @@ namespace octa {
/* pointer traits */ /* pointer traits */
template<typename _T> template<typename _T>
struct __OctaHasElementType { struct __OctaHasElement {
template<typename _U> template<typename _U>
static int __test(...); static int __test(...);
template<typename _U> template<typename _U>
static char __test(typename _U::ElementType * = 0); static char __test(typename _U::Element * = 0);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _T, bool = __OctaHasElementType<_T>::value> template<typename _T, bool = __OctaHasElement<_T>::value>
struct __OctaPtrTraitsElementType; struct __OctaPtrTraitsElementType;
template<typename _T> struct __OctaPtrTraitsElementType<_T, true> { template<typename _T> struct __OctaPtrTraitsElementType<_T, true> {
typedef typename _T::ElementType Type; typedef typename _T::Element Type;
}; };
template<template<typename, typename...> class _T, typename _U, typename ..._A> template<template<typename, typename...> class _T, typename _U, typename ..._A>
struct __OctaPtrTraitsElementType<_T<_U, _A...>, true> { struct __OctaPtrTraitsElementType<_T<_U, _A...>, true> {
typedef typename _T<_U, _A...>::ElementType Type; typedef typename _T<_U, _A...>::Element Type;
}; };
template<template<typename, typename...> class _T, typename _U, typename ..._A> template<template<typename, typename...> class _T, typename _U, typename ..._A>
@ -50,22 +50,22 @@ namespace octa {
}; };
template<typename _T> template<typename _T>
struct __OctaHasDiffType { struct __OctaHasDifference {
template<typename _U> template<typename _U>
static int __test(...); static int __test(...);
template<typename _U> template<typename _U>
static char __test(typename _U::DiffType * = 0); static char __test(typename _U::Difference * = 0);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _T, bool = __OctaHasDiffType<_T>::value> template<typename _T, bool = __OctaHasDifference<_T>::value>
struct __OctaPtrTraitsDiffType { struct __OctaPtrTraitsDifferenceType {
typedef ptrdiff_t Type; typedef ptrdiff_t Type;
}; };
template<typename _T> struct __OctaPtrTraitsDiffType<_T, true> { template<typename _T> struct __OctaPtrTraitsDifferenceType<_T, true> {
typedef typename _T::DiffType Type; typedef typename _T::Difference Type;
}; };
template<typename _T, typename _U> template<typename _T, typename _U>
@ -108,7 +108,7 @@ namespace octa {
}; };
template<typename _T> template<typename _T>
using PtrType = typename __OctaPtrTraitsPointer<_T>::Type; using Pointer = typename __OctaPtrTraitsPointer<_T>::Type;
template<typename _T> template<typename _T>
struct __OctaPtrTraitsElement { struct __OctaPtrTraitsElement {
@ -125,13 +125,13 @@ namespace octa {
template<typename _T> template<typename _T>
struct __OctaPtrTraitsDifference { struct __OctaPtrTraitsDifference {
typedef typename __OctaPtrTraitsDiffType<_T>::Type Type; typedef typename __OctaPtrTraitsDifferenceType<_T>::Type Type;
}; };
template<typename _T> template<typename _T>
struct __OctaPtrTraitsDifference<_T *> { struct __OctaPtrTraitsDifference<_T *> {
typedef ptrdiff_t DiffType; typedef ptrdiff_t Type;
}; };
template<typename _T> template<typename _T>
@ -248,30 +248,30 @@ namespace octa {
template<typename _T> template<typename _T>
static int __octa_ptr_test(...); static int __octa_ptr_test(...);
template<typename _T> template<typename _T>
static char __octa_ptr_test(typename _T::PtrType * = 0); static char __octa_ptr_test(typename _T::Pointer * = 0);
template<typename _T> struct __OctaHasPtr: octa::IntegralConstant<bool, template<typename _T> struct __OctaHasPtr: octa::IntegralConstant<bool,
(sizeof(__octa_ptr_test<_T>(0)) == 1) (sizeof(__octa_ptr_test<_T>(0)) == 1)
> {}; > {};
template<typename _T, typename _D, bool = __OctaHasPtr<_D>::value> template<typename _T, typename _D, bool = __OctaHasPtr<_D>::value>
struct __OctaPtrTypeBase { struct __OctaPointerBase {
typedef typename _D::PtrType Type; typedef typename _D::Pointer Type;
}; };
template<typename _T, typename _D> struct __OctaPtrTypeBase<_T, _D, false> { template<typename _T, typename _D> struct __OctaPointerBase<_T, _D, false> {
typedef _T *Type; typedef _T *Type;
}; };
template<typename _T, typename _D> struct __OctaPtrType { template<typename _T, typename _D> struct __OctaPointer {
typedef typename __OctaPtrTypeBase<_T, octa::RemoveReference<_D>>::Type Type; typedef typename __OctaPointerBase<_T, octa::RemoveReference<_D>>::Type Type;
}; };
template<typename _T, typename _D = DefaultDelete<_T>> template<typename _T, typename _D = DefaultDelete<_T>>
struct Box { struct Box {
typedef _T ElementType; typedef _T Element;
typedef _D DeleterType; typedef _D Deleter;
typedef typename __OctaPtrType<_T, _D>::Type PtrType; typedef typename __OctaPointer<_T, _D>::Type Pointer;
private: private:
struct __OctaNat { int __x; }; struct __OctaNat { int __x; };
@ -289,16 +289,16 @@ namespace octa {
"Box constructed with null fptr deleter"); "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, static_assert(!octa::IsPointer<_D>::value,
"Box constructed with null fptr deleter"); "Box constructed with null fptr deleter");
} }
Box(PtrType __p, octa::Conditional<octa::IsReference<_D>::value, Box(Pointer __p, octa::Conditional<octa::IsReference<_D>::value,
_D, octa::AddLvalueReference<const _D> _D, octa::AddLvalueReference<const _D>
> __d): __stor(__p, __d) {} > __d): __stor(__p, __d) {}
Box(PtrType __p, octa::RemoveReference<_D> &&__d): Box(Pointer __p, octa::RemoveReference<_D> &&__d):
__stor(__p, octa::move(__d)) { __stor(__p, octa::move(__d)) {
static_assert(!octa::IsReference<_D>::value, static_assert(!octa::IsReference<_D>::value,
"rvalue deleter cannot be a ref"); "rvalue deleter cannot be a ref");
@ -309,7 +309,7 @@ namespace octa {
template<typename _TT, typename _DD> template<typename _TT, typename _DD>
Box(Box<_TT, _DD> &&__u, octa::EnableIf<!octa::IsArray<_TT>::value Box(Box<_TT, _DD> &&__u, octa::EnableIf<!octa::IsArray<_TT>::value
&& octa::IsConvertible<typename Box<_TT, _DD>::PtrType, PtrType>::value && octa::IsConvertible<typename Box<_TT, _DD>::Pointer, Pointer>::value
&& octa::IsConvertible<_DD, _D>::value && octa::IsConvertible<_DD, _D>::value
&& (!octa::IsReference<_D>::value || octa::IsSame<_D, _DD>::value) && (!octa::IsReference<_D>::value || octa::IsSame<_D, _DD>::value)
> = __OctaNat()): __stor(__u.release(), octa::forward<_DD>(__u.get_deleter())) {} > = __OctaNat()): __stor(__u.release(), octa::forward<_DD>(__u.get_deleter())) {}
@ -322,7 +322,7 @@ namespace octa {
template<typename _TT, typename _DD> template<typename _TT, typename _DD>
EnableIf<!octa::IsArray<_TT>::value EnableIf<!octa::IsArray<_TT>::value
&& octa::IsConvertible<typename Box<_TT, _DD>::PtrType, PtrType>::value && octa::IsConvertible<typename Box<_TT, _DD>::Pointer, Pointer>::value
&& octa::IsAssignable<_D &, _DD &&>::value, && octa::IsAssignable<_D &, _DD &&>::value,
Box & Box &
> operator=(Box<_TT, _DD> &&__u) { > operator=(Box<_TT, _DD> &&__u) {
@ -339,25 +339,25 @@ namespace octa {
~Box() { reset(); } ~Box() { reset(); }
octa::AddLvalueReference<_T> operator*() const { return *__stor.__ptr; } octa::AddLvalueReference<_T> operator*() const { return *__stor.__ptr; }
PtrType operator->() const { return __stor.__ptr; } Pointer operator->() const { return __stor.__ptr; }
explicit operator bool() const { explicit operator bool() const {
return __stor.__ptr != nullptr; 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_ref get_deleter() { return __stor.get_deleter(); }
_D_cref get_deleter() const { return __stor.get_deleter(); } _D_cref get_deleter() const { return __stor.get_deleter(); }
PtrType release() { Pointer release() {
PtrType __p = __stor.__ptr; Pointer __p = __stor.__ptr;
__stor.__ptr = nullptr; __stor.__ptr = nullptr;
return __p; return __p;
} }
void reset(PtrType __p = nullptr) { void reset(Pointer __p = nullptr) {
PtrType __tmp = __stor.__ptr; Pointer __tmp = __stor.__ptr;
__stor.__ptr = __p; __stor.__ptr = __p;
if (__tmp) __stor.get_deleter()(__tmp); if (__tmp) __stor.get_deleter()(__tmp);
} }
@ -379,7 +379,7 @@ namespace octa {
struct __OctaSameOrLessCvQualifiedBase<_T, _U, false>: octa::False {}; struct __OctaSameOrLessCvQualifiedBase<_T, _U, false>: octa::False {};
template<typename _T, typename _U, bool = octa::IsPointer<_T>::value template<typename _T, typename _U, bool = octa::IsPointer<_T>::value
|| octa::IsSame<_T, _U>::value || __OctaHasElementType<_T>::value || octa::IsSame<_T, _U>::value || __OctaHasElement<_T>::value
> struct __OctaSameOrLessCvQualified: __OctaSameOrLessCvQualifiedBase<_T, _U> {}; > struct __OctaSameOrLessCvQualified: __OctaSameOrLessCvQualifiedBase<_T, _U> {};
template<typename _T, typename _U> template<typename _T, typename _U>
@ -387,9 +387,9 @@ namespace octa {
template<typename _T, typename _D> template<typename _T, typename _D>
struct Box<_T[], _D> { struct Box<_T[], _D> {
typedef _T ElementType; typedef _T Element;
typedef _D DeleterType; typedef _D Deleter;
typedef typename __OctaPtrType<_T, _D>::Type PtrType; typedef typename __OctaPointer<_T, _D>::Type Pointer;
private: private:
struct __OctaNat { int __x; }; struct __OctaNat { int __x; };
@ -408,7 +408,7 @@ namespace octa {
} }
template<typename _U> explicit Box(_U __p, octa::EnableIf< template<typename _U> explicit Box(_U __p, octa::EnableIf<
__OctaSameOrLessCvQualified<_U, PtrType>::value, __OctaNat __OctaSameOrLessCvQualified<_U, Pointer>::value, __OctaNat
> = __OctaNat()): __stor(__p, _D()) { > = __OctaNat()): __stor(__p, _D()) {
static_assert(!octa::IsPointer<_D>::value, static_assert(!octa::IsPointer<_D>::value,
"Box constructed with null fptr deleter"); "Box constructed with null fptr deleter");
@ -417,7 +417,7 @@ namespace octa {
template<typename _U> Box(_U __p, octa::Conditional< template<typename _U> Box(_U __p, octa::Conditional<
octa::IsReference<_D>::value, octa::IsReference<_D>::value,
_D, AddLvalueReference<const _D> _D, AddLvalueReference<const _D>
> __d, octa::EnableIf<__OctaSameOrLessCvQualified<_U, PtrType>::value, > __d, octa::EnableIf<__OctaSameOrLessCvQualified<_U, Pointer>::value,
__OctaNat> = __OctaNat()): __stor(__p, __d) {} __OctaNat> = __OctaNat()): __stor(__p, __d) {}
Box(nullptr_t, octa::Conditional<octa::IsReference<_D>::value, Box(nullptr_t, octa::Conditional<octa::IsReference<_D>::value,
@ -426,7 +426,7 @@ namespace octa {
template<typename _U> Box(_U __p, octa::RemoveReference<_D> &&__d, template<typename _U> Box(_U __p, octa::RemoveReference<_D> &&__d,
octa::EnableIf< octa::EnableIf<
__OctaSameOrLessCvQualified<_U, PtrType>::value, __OctaNat __OctaSameOrLessCvQualified<_U, Pointer>::value, __OctaNat
> = __OctaNat()): __stor(__p, octa::move(__d)) { > = __OctaNat()): __stor(__p, octa::move(__d)) {
static_assert(!octa::IsReference<_D>::value, static_assert(!octa::IsReference<_D>::value,
"rvalue deleter cannot be a ref"); "rvalue deleter cannot be a ref");
@ -443,8 +443,8 @@ namespace octa {
template<typename _TT, typename _DD> template<typename _TT, typename _DD>
Box(Box<_TT, _DD> &&__u, EnableIf<IsArray<_TT>::value Box(Box<_TT, _DD> &&__u, EnableIf<IsArray<_TT>::value
&& __OctaSameOrLessCvQualified<typename Box<_TT, _DD>::PtrType, && __OctaSameOrLessCvQualified<typename Box<_TT, _DD>::Pointer,
PtrType>::value Pointer>::value
&& octa::IsConvertible<_DD, _D>::value && octa::IsConvertible<_DD, _D>::value
&& (!octa::IsReference<_D>::value || && (!octa::IsReference<_D>::value ||
octa::IsSame<_D, _DD>::value)> = __OctaNat() octa::IsSame<_D, _DD>::value)> = __OctaNat()
@ -458,8 +458,8 @@ namespace octa {
template<typename _TT, typename _DD> template<typename _TT, typename _DD>
EnableIf<octa::IsArray<_TT>::value EnableIf<octa::IsArray<_TT>::value
&& __OctaSameOrLessCvQualified<typename Box<_TT, _DD>::PtrType, && __OctaSameOrLessCvQualified<typename Box<_TT, _DD>::Pointer,
PtrType>::value Pointer>::value
&& IsAssignable<_D &, _DD &&>::value, && IsAssignable<_D &, _DD &&>::value,
Box & Box &
> operator=(Box<_TT, _DD> &&__u) { > operator=(Box<_TT, _DD> &&__u) {
@ -483,27 +483,27 @@ namespace octa {
return __stor.__ptr != nullptr; 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_ref get_deleter() { return __stor.get_deleter(); }
_D_cref get_deleter() const { return __stor.get_deleter(); } _D_cref get_deleter() const { return __stor.get_deleter(); }
PtrType release() { Pointer release() {
PtrType __p = __stor.__ptr; Pointer __p = __stor.__ptr;
__stor.__ptr = nullptr; __stor.__ptr = nullptr;
return __p; return __p;
} }
template<typename _U> EnableIf< template<typename _U> EnableIf<
__OctaSameOrLessCvQualified<_U, PtrType>::value, void __OctaSameOrLessCvQualified<_U, Pointer>::value, void
> reset(_U __p) { > reset(_U __p) {
PtrType __tmp = __stor.__ptr; Pointer __tmp = __stor.__ptr;
__stor.__ptr = __p; __stor.__ptr = __p;
if (__tmp) __stor.get_deleter()(__tmp); if (__tmp) __stor.get_deleter()(__tmp);
} }
void reset(nullptr_t) { void reset(nullptr_t) {
PtrType __tmp = __stor.__ptr; Pointer __tmp = __stor.__ptr;
__stor.__ptr = nullptr; __stor.__ptr = nullptr;
if (__tmp) __stor.get_deleter()(__tmp); if (__tmp) __stor.get_deleter()(__tmp);
} }
@ -550,84 +550,84 @@ namespace octa {
template<typename> struct Allocator; template<typename> struct Allocator;
template<> struct Allocator<void> { template<> struct Allocator<void> {
typedef void ValType; typedef void Value;
typedef void *PtrType; typedef void *Pointer;
typedef const void *ConstPtrType; typedef const void *ConstPointer;
template<typename _U> using Rebind = Allocator<_U>; template<typename _U> using Rebind = Allocator<_U>;
}; };
template<> struct Allocator<const void> { template<> struct Allocator<const void> {
typedef const void ValType; typedef const void Value;
typedef const void *PtrType; typedef const void *Pointer;
typedef const void *ConstPtrType; typedef const void *ConstPointer;
template<typename _U> using Rebind = Allocator<_U>; template<typename _U> using Rebind = Allocator<_U>;
}; };
template<typename _T> struct Allocator { template<typename _T> struct Allocator {
typedef size_t SizeType; typedef size_t Size;
typedef ptrdiff_t DiffType; typedef ptrdiff_t Difference;
typedef _T ValType; typedef _T Value;
typedef _T &RefType; typedef _T &Reference;
typedef const _T &ConstRefType; typedef const _T &ConstReference;
typedef _T *PtrType; typedef _T *Pointer;
typedef const _T *ConstPtrType; typedef const _T *ConstPointer;
template<typename _U> using Rebind = Allocator<_U>; template<typename _U> using Rebind = Allocator<_U>;
PtrType address(RefType __v) const { Pointer address(Reference __v) const {
return address_of(__v); return address_of(__v);
}; };
ConstPtrType address(ConstRefType __v) const { ConstPointer address(ConstReference __v) const {
return address_of(__v); 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<void>::ConstPtrType = nullptr) { Pointer allocate(Size __n, Allocator<void>::ConstPointer = nullptr) {
return (PtrType) ::new uchar[__n * sizeof(_T)]; return (Pointer) ::new uchar[__n * sizeof(_T)];
} }
void deallocate(PtrType __p, SizeType) { ::delete[] (uchar *) __p; } void deallocate(Pointer __p, Size) { ::delete[] (uchar *) __p; }
template<typename _U, typename ..._A> template<typename _U, typename ..._A>
void construct(_U *__p, _A &&...__args) { void construct(_U *__p, _A &&...__args) {
::new((void *)__p) _U(octa::forward<_A>(__args)...); ::new((void *)__p) _U(octa::forward<_A>(__args)...);
} }
void destroy(PtrType __p) { __p->~_T(); } void destroy(Pointer __p) { __p->~_T(); }
}; };
template<typename _T> struct Allocator<const _T> { template<typename _T> struct Allocator<const _T> {
typedef size_t SizeType; typedef size_t Size;
typedef ptrdiff_t DiffType; typedef ptrdiff_t Difference;
typedef const _T ValType; typedef const _T Value;
typedef const _T &RefType; typedef const _T &Reference;
typedef const _T &ConstRefType; typedef const _T &ConstReference;
typedef const _T *PtrType; typedef const _T *Pointer;
typedef const _T *ConstPtrType; typedef const _T *ConstPointer;
template<typename _U> using Rebind = Allocator<_U>; template<typename _U> using Rebind = Allocator<_U>;
ConstPtrType address(ConstRefType __v) const { ConstPointer address(ConstReference __v) const {
return address_of(__v); 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<void>::ConstPtrType = nullptr) { Pointer allocate(Size __n, Allocator<void>::ConstPointer = nullptr) {
return (PtrType) ::new uchar[__n * sizeof(_T)]; return (Pointer) ::new uchar[__n * sizeof(_T)];
} }
void deallocate(PtrType __p, SizeType) { ::delete[] (uchar *) __p; } void deallocate(Pointer __p, Size) { ::delete[] (uchar *) __p; }
template<typename _U, typename ..._A> template<typename _U, typename ..._A>
void construct(_U *__p, _A &&...__args) { void construct(_U *__p, _A &&...__args) {
::new((void *)__p) _U(octa::forward<_A>(__args)...); ::new((void *)__p) _U(octa::forward<_A>(__args)...);
} }
void destroy(PtrType __p) { __p->~_T(); } void destroy(Pointer __p) { __p->~_T(); }
}; };
template<typename _T, typename _U> template<typename _T, typename _U>
@ -645,73 +645,73 @@ namespace octa {
template<typename _T> template<typename _T>
struct __OctaConstPtrTest { struct __OctaConstPtrTest {
template<typename _U> static char __test( template<typename _U> static char __test(
typename _U::ConstPtrType * = 0); typename _U::ConstPointer * = 0);
template<typename _U> static int __test(...); template<typename _U> static int __test(...);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _T, typename _P, typename _A, template<typename _T, typename _P, typename _A,
bool = __OctaConstPtrTest<_A>::value> bool = __OctaConstPtrTest<_A>::value>
struct __OctaConstPtrType { struct __OctaConstPointer {
typedef typename _A::ConstPtrType Type; typedef typename _A::ConstPointer Type;
}; };
template<typename _T, typename _P, typename _A> template<typename _T, typename _P, typename _A>
struct __OctaConstPtrType<_T, _P, _A, false> { struct __OctaConstPointer<_T, _P, _A, false> {
typedef PointerRebind<_P, const _T> Type; typedef PointerRebind<_P, const _T> Type;
}; };
template<typename _T> template<typename _T>
struct __OctaVoidPtrTest { struct __OctaVoidPtrTest {
template<typename _U> static char __test( template<typename _U> static char __test(
typename _U::VoidPtrType * = 0); typename _U::VoidPointer * = 0);
template<typename _U> static int __test(...); template<typename _U> static int __test(...);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _P, typename _A, bool = __OctaVoidPtrTest<_A>::value> template<typename _P, typename _A, bool = __OctaVoidPtrTest<_A>::value>
struct __OctaVoidPtrType { struct __OctaVoidPointer {
typedef typename _A::VoidPtrType Type; typedef typename _A::VoidPointer Type;
}; };
template<typename _P, typename _A> template<typename _P, typename _A>
struct __OctaVoidPtrType<_P, _A, false> { struct __OctaVoidPointer<_P, _A, false> {
typedef PointerRebind<_P, void> Type; typedef PointerRebind<_P, void> Type;
}; };
template<typename _T> template<typename _T>
struct __OctaConstVoidPtrTest { struct __OctaConstVoidPtrTest {
template<typename _U> static char __test( template<typename _U> static char __test(
typename _U::ConstVoidPtrType * = 0); typename _U::ConstVoidPointer * = 0);
template<typename _U> static int __test(...); template<typename _U> static int __test(...);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _P, typename _A, bool = __OctaConstVoidPtrTest<_A>::value> template<typename _P, typename _A, bool = __OctaConstVoidPtrTest<_A>::value>
struct __OctaConstVoidPtrType { struct __OctaConstVoidPointer {
typedef typename _A::ConstVoidPtrType Type; typedef typename _A::ConstVoidPointer Type;
}; };
template<typename _P, typename _A> template<typename _P, typename _A>
struct __OctaConstVoidPtrType<_P, _A, false> { struct __OctaConstVoidPointer<_P, _A, false> {
typedef PointerRebind<_P, const void> Type; typedef PointerRebind<_P, const void> Type;
}; };
template<typename _T> template<typename _T>
struct __OctaSizeTest { struct __OctaSizeTest {
template<typename _U> static char __test(typename _U::SizeType * = 0); template<typename _U> static char __test(typename _U::Size * = 0);
template<typename _U> static int __test(...); template<typename _U> static int __test(...);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _A, typename _D, bool = __OctaSizeTest<_A>::value> template<typename _A, typename _D, bool = __OctaSizeTest<_A>::value>
struct __OctaSizeType { struct __OctaSize {
typedef octa::MakeUnsigned<_D> Type; typedef octa::MakeUnsigned<_D> Type;
}; };
template<typename _A, typename _D> template<typename _A, typename _D>
struct __OctaSizeType<_A, _D, true> { struct __OctaSize<_A, _D, true> {
typedef typename _A::SizeType Type; typedef typename _A::Size Type;
}; };
/* allocator type traits */ /* allocator type traits */
@ -720,25 +720,25 @@ namespace octa {
using AllocatorType = _A; using AllocatorType = _A;
template<typename _A> template<typename _A>
using AllocatorValue = typename AllocatorType<_A>::ValType; using AllocatorValue = typename AllocatorType<_A>::Value;
template<typename _A> template<typename _A>
using AllocatorPointer = typename __OctaPtrType< using AllocatorPointer = typename __OctaPointer<
AllocatorValue<_A>, AllocatorType <_A> AllocatorValue<_A>, AllocatorType <_A>
>::Type; >::Type;
template<typename _A> template<typename _A>
using AllocatorConstPointer = typename __OctaConstPtrType< using AllocatorConstPointer = typename __OctaConstPointer<
AllocatorValue<_A>, AllocatorPointer<_A>, AllocatorType<_A> AllocatorValue<_A>, AllocatorPointer<_A>, AllocatorType<_A>
>::Type; >::Type;
template<typename _A> template<typename _A>
using AllocatorVoidPointer = typename __OctaVoidPtrType< using AllocatorVoidPointer = typename __OctaVoidPointer<
AllocatorPointer<_A>, AllocatorType<_A> AllocatorPointer<_A>, AllocatorType<_A>
>::Type; >::Type;
template<typename _A> template<typename _A>
using AllocatorConstVoidPointer = typename __OctaConstVoidPtrType< using AllocatorConstVoidPointer = typename __OctaConstVoidPointer<
AllocatorPointer<_A>, AllocatorType<_A> AllocatorPointer<_A>, AllocatorType<_A>
>::Type; >::Type;
@ -746,30 +746,30 @@ namespace octa {
template<typename _T> template<typename _T>
struct __OctaDiffTest { struct __OctaDiffTest {
template<typename _U> static char __test(typename _U::DiffType * = 0); template<typename _U> static char __test(typename _U::Difference * = 0);
template<typename _U> static int __test(...); template<typename _U> static int __test(...);
static constexpr bool value = (sizeof(__test<_T>(0)) == 1); static constexpr bool value = (sizeof(__test<_T>(0)) == 1);
}; };
template<typename _A, typename _P, bool = __OctaDiffTest<_A>::value> template<typename _A, typename _P, bool = __OctaDiffTest<_A>::value>
struct __OctaAllocDiffType { struct __OctaAllocDifference {
typedef PointerDifference<_P> Type; typedef PointerDifference<_P> Type;
}; };
template<typename _A, typename _P> template<typename _A, typename _P>
struct __OctaAllocDiffType<_A, _P, true> { struct __OctaAllocDifference<_A, _P, true> {
typedef typename _A::DiffType Type; typedef typename _A::Difference Type;
}; };
template<typename _A> template<typename _A>
using AllocatorDifference = typename __OctaAllocDiffType< using AllocatorDifference = typename __OctaAllocDifference<
_A, AllocatorPointer<_A> _A, AllocatorPointer<_A>
>::Type; >::Type;
/* allocator size */ /* allocator size */
template<typename _A> template<typename _A>
using AllocatorSize = typename __OctaSizeType< using AllocatorSize = typename __OctaSize<
_A, AllocatorDifference<_A> _A, AllocatorDifference<_A>
>::Type; >::Type;

View File

@ -35,10 +35,10 @@ namespace octa {
using Range##_Name = typename __OctaRange##_Name<_T>::Type; using Range##_Name = typename __OctaRange##_Name<_T>::Type;
__OCTA_RANGE_TRAIT(Category, Category) __OCTA_RANGE_TRAIT(Category, Category)
__OCTA_RANGE_TRAIT(Size, SizeType) __OCTA_RANGE_TRAIT(Size, Size)
__OCTA_RANGE_TRAIT(Value, ValType) __OCTA_RANGE_TRAIT(Value, Value)
__OCTA_RANGE_TRAIT(Reference, RefType) __OCTA_RANGE_TRAIT(Reference, Reference)
__OCTA_RANGE_TRAIT(Difference, DiffType) __OCTA_RANGE_TRAIT(Difference, Difference)
#undef __OCTA_RANGE_TRAIT #undef __OCTA_RANGE_TRAIT
@ -139,7 +139,7 @@ namespace octa {
private: private:
_T __range; _T __range;
public: public:
typedef _T RangeType; typedef _T Range;
RangeHalf(): __range() {} RangeHalf(): __range() {}
RangeHalf(const _T &__range): __range(__range) {} RangeHalf(const _T &__range): __range(__range) {}
@ -279,10 +279,10 @@ namespace octa {
typename _S = size_t, typename _D = ptrdiff_t typename _S = size_t, typename _D = ptrdiff_t
> struct InputRange { > struct InputRange {
typedef _C Category; typedef _C Category;
typedef _S SizeType; typedef _S Size;
typedef _D DiffType; typedef _D Difference;
typedef _V ValType; typedef _V Value;
typedef _R RefType; typedef _R Reference;
__OctaRangeIterator<_B> begin() const { __OctaRangeIterator<_B> begin() const {
return __OctaRangeIterator<_B>((const _B &)*this); return __OctaRangeIterator<_B>((const _B &)*this);
@ -291,19 +291,19 @@ namespace octa {
return __OctaRangeIterator<_B>(); return __OctaRangeIterator<_B>();
} }
SizeType pop_front_n(SizeType __n) { Size pop_front_n(Size __n) {
return __octa_pop_front_n<_B>(*((_B *)this), __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); 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); 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); return __octa_push_back_n<_B>(*((_B *)this), __n);
} }
@ -320,10 +320,10 @@ namespace octa {
typename _D = ptrdiff_t typename _D = ptrdiff_t
> struct OutputRange { > struct OutputRange {
typedef OutputRangeTag Category; typedef OutputRangeTag Category;
typedef _S SizeType; typedef _S Size;
typedef _D DiffType; typedef _D Difference;
typedef _V ValType; typedef _V Value;
typedef _R RefType; typedef _R Reference;
}; };
template<typename _T> template<typename _T>

View File

@ -25,15 +25,15 @@ namespace octa {
} }
public: public:
typedef size_t SizeType; typedef size_t Size;
typedef ptrdiff_t DiffType; typedef ptrdiff_t Difference;
typedef _T ValType; typedef _T Value;
typedef _T &RefType; typedef _T &Reference;
typedef const _T &ConstRefType; typedef const _T &ConstReference;
typedef _T *PtrType; typedef _T *Pointer;
typedef const _T *ConstPtrType; typedef const _T *ConstPointer;
typedef PointerRange< _T> RangeType; typedef PointerRange< _T> Range;
typedef PointerRange<const _T> ConstRangeType; typedef PointerRange<const _T> ConstRange;
StringBase(): __buf(1, '\0') {} StringBase(): __buf(1, '\0') {}
@ -47,7 +47,7 @@ namespace octa {
} }
/* TODO: traits for utf-16/utf-32 string lengths, for now assume char */ /* 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<typename _R> StringBase(_R __range): __buf(__range) { template<typename _R> StringBase(_R __range): __buf(__range) {
__terminate(); __terminate();
@ -64,7 +64,7 @@ namespace octa {
return *this; return *this;
} }
StringBase<_T> &operator=(const _T *__v) { StringBase<_T> &operator=(const _T *__v) {
__buf = ConstRangeType(__v, strlen(__v) + 1); __buf = ConstRange(__v, strlen(__v) + 1);
return *this; return *this;
} }
@ -124,7 +124,7 @@ namespace octa {
StringBase<_T> &append(const _T *__s) { StringBase<_T> &append(const _T *__s) {
__buf.pop(); __buf.pop();
__buf.insert_range(__buf.size(), ConstRangeType(__s, __buf.insert_range(__buf.size(), ConstRange(__s,
strlen(__s) + 1)); strlen(__s) + 1));
return *this; return *this;
} }
@ -157,11 +157,11 @@ namespace octa {
return *this; return *this;
} }
RangeType each() { Range each() {
return RangeType(__buf.data(), size()); return Range(__buf.data(), size());
} }
ConstRangeType each() const { ConstRange each() const {
return ConstRangeType(__buf.data(), size()); return ConstRange(__buf.data(), size());
} }
void swap(StringBase &__v) { void swap(StringBase &__v) {
@ -225,8 +225,8 @@ namespace octa {
}; };
template<typename _T> struct ToString { template<typename _T> struct ToString {
typedef _T ArgType; typedef _T Argument;
typedef String ResultType; typedef String Result;
template<typename _U> template<typename _U>
static String __octa_to_str(const _U &__v, static String __octa_to_str(const _U &__v,
@ -281,16 +281,16 @@ namespace octa {
} }
template<> struct ToString<bool> { template<> struct ToString<bool> {
typedef bool ArgType; typedef bool Argument;
typedef String ResultType; typedef String Result;
String operator()(bool __b) { String operator()(bool __b) {
return __b ? "true" : "false"; return __b ? "true" : "false";
} }
}; };
template<> struct ToString<char> { template<> struct ToString<char> {
typedef char ArgType; typedef char Argument;
typedef String ResultType; typedef String Result;
String operator()(char __c) { String operator()(char __c) {
String __ret; String __ret;
__ret.push(__c); __ret.push(__c);
@ -300,8 +300,8 @@ namespace octa {
#define __OCTA_TOSTR_NUM(_T, __fmt) \ #define __OCTA_TOSTR_NUM(_T, __fmt) \
template<> struct ToString<_T> { \ template<> struct ToString<_T> { \
typedef _T ArgType; \ typedef _T Argument; \
typedef String ResultType; \ typedef String Result; \
String operator()(_T __v) { \ String operator()(_T __v) { \
String __ret; \ String __ret; \
__octa_str_printf((octa::Vector<char> *)&__ret, __fmt, __v); \ __octa_str_printf((octa::Vector<char> *)&__ret, __fmt, __v); \
@ -323,9 +323,9 @@ namespace octa {
#undef __OCTA_TOSTR_NUM #undef __OCTA_TOSTR_NUM
template<typename _T> struct ToString<_T *> { template<typename _T> struct ToString<_T *> {
typedef _T *ArgType; typedef _T *Argument;
typedef String ResultType; typedef String Result;
String operator()(ArgType __v) { String operator()(Argument __v) {
String __ret; String __ret;
__octa_str_printf((octa::Vector<char> *)&__ret, "%p", __v); __octa_str_printf((octa::Vector<char> *)&__ret, "%p", __v);
return octa::move(__ret); return octa::move(__ret);
@ -333,17 +333,17 @@ namespace octa {
}; };
template<> struct ToString<String> { template<> struct ToString<String> {
typedef const String &ArgType; typedef const String &Argument;
typedef String ResultType; typedef String Result;
String operator()(ArgType __s) { String operator()(Argument __s) {
return __s; return __s;
} }
}; };
template<typename _T, typename _U> struct ToString<octa::Pair<_T, _U>> { template<typename _T, typename _U> struct ToString<octa::Pair<_T, _U>> {
typedef const octa::Pair<_T, _U> &ArgType; typedef const octa::Pair<_T, _U> &Argument;
typedef String ResultType; typedef String Result;
String operator()(ArgType __v) { String operator()(Argument __v) {
String __ret("{"); String __ret("{");
__ret += ToString<octa::RemoveCv<octa::RemoveReference<_T>>>() __ret += ToString<octa::RemoveCv<octa::RemoveReference<_T>>>()
(__v.first); (__v.first);

View File

@ -51,11 +51,11 @@ namespace octa {
struct IntegralConstant { struct IntegralConstant {
static constexpr _T value = __val; static constexpr _T value = __val;
typedef _T ValType; typedef _T Value;
typedef IntegralConstant<_T, __val> Type; typedef IntegralConstant<_T, __val> Type;
constexpr operator ValType() const { return value; } constexpr operator Value() const { return value; }
constexpr ValType operator()() const { return value; } constexpr Value operator()() const { return value; }
}; };
typedef IntegralConstant<bool, true> True; typedef IntegralConstant<bool, true> True;

View File

@ -59,15 +59,15 @@ namespace octa {
public: public:
enum { MIN_SIZE = 8 }; enum { MIN_SIZE = 8 };
typedef size_t SizeType; typedef size_t Size;
typedef ptrdiff_t DiffType; typedef ptrdiff_t Difference;
typedef _T ValType; typedef _T Value;
typedef _T &RefType; typedef _T &Reference;
typedef const _T &ConstRefType; typedef const _T &ConstReference;
typedef _T *PtrType; typedef _T *Pointer;
typedef const _T *ConstPtrType; typedef const _T *ConstPointer;
typedef PointerRange< _T> RangeType; typedef PointerRange< _T> Range;
typedef PointerRange<const _T> ConstRangeType; typedef PointerRange<const _T> ConstRange;
Vector(): __buf(nullptr), __len(0), __cap(0) {} Vector(): __buf(nullptr), __len(0), __cap(0) {}
@ -297,11 +297,11 @@ namespace octa {
return insert_range(__idx, octa::each(__il)); return insert_range(__idx, octa::each(__il));
} }
RangeType each() { Range each() {
return RangeType(__buf, __buf + __len); return Range(__buf, __buf + __len);
} }
ConstRangeType each() const { ConstRange each() const {
return ConstRangeType(__buf, __buf + __len); return ConstRange(__buf, __buf + __len);
} }
void swap(Vector &__v) { void swap(Vector &__v) {