diff --git a/COPYING.md b/COPYING.md index 5ef1ee0..f9995e4 100644 --- a/COPYING.md +++ b/COPYING.md @@ -27,4 +27,10 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE.** \ No newline at end of file +SOFTWARE.** + +Additionally some code from the libc++ project has been used as a reference; +libc++ is a part of the LLVM project. + +Additional thanks to Dale Weiler aka graphitemaster (reference code in the +Neothyne project) and cppreference.com. \ No newline at end of file diff --git a/octa/functional.h b/octa/functional.h index 7d97cc3..1d92682 100644 --- a/octa/functional.h +++ b/octa/functional.h @@ -228,7 +228,7 @@ namespace octa { }; template - struct FunctorDataManager + struct FunctorDataManager ::value>::type> { template static R call(const FunctorData &s, A ...args) { diff --git a/octa/traits.h b/octa/traits.h index f7bd752..cf2b7f5 100644 --- a/octa/traits.h +++ b/octa/traits.h @@ -11,15 +11,17 @@ #include "octa/types.h" #include "octa/utility.h" -/* libc++ and cppreference.com occasionally used for reference */ - -/* missing: - * - * UnderlyingType - */ - namespace octa { - template struct RemoveConstVolatile; + /* forward declarations */ + + template struct RemoveCV; + template struct AddLvalueReference; + template struct AddConst; + template struct IsReference; + template struct RemoveAllExtents; + template struct IsTriviallyDefaultConstructible; + + template struct CommonType; /* integral constant */ @@ -41,52 +43,51 @@ namespace octa { /* is void */ - template struct IsVoidBase : false_t {}; - template< > struct IsVoidBase: true_t {}; + template struct __OctaIsVoid : false_t {}; + template< > struct __OctaIsVoid: true_t {}; template - struct IsVoid: IsVoidBase::type> {}; + struct IsVoid: __OctaIsVoid::type> {}; /* is null pointer */ - template struct IsNullPointerBase : false_t {}; - template< > struct IsNullPointerBase: true_t {}; + template struct __OctaIsNullPointer : false_t {}; + template< > struct __OctaIsNullPointer: true_t {}; - template - struct IsNullPointer: IsNullPointerBase< - typename RemoveConstVolatile::type + template struct IsNullPointer: __OctaIsNullPointer< + typename RemoveCV::type > {}; /* is integer */ - template struct IsIntegralBase: false_t {}; + template struct __OctaIsIntegral: false_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; - template<> struct IsIntegralBase: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; + template<> struct __OctaIsIntegral: true_t {}; template - struct IsIntegral: IsIntegralBase::type> {}; + struct IsIntegral: __OctaIsIntegral::type> {}; /* is floating point */ - template struct IsFloatingPointBase : false_t {}; + template struct __OctaIsFloatingPoint: false_t {}; - template<> struct IsFloatingPointBase: true_t {}; - template<> struct IsFloatingPointBase: true_t {}; - template<> struct IsFloatingPointBase: true_t {}; + template<> struct __OctaIsFloatingPoint: true_t {}; + template<> struct __OctaIsFloatingPoint: true_t {}; + template<> struct __OctaIsFloatingPoint: true_t {}; template - struct IsFloatingPoint: IsFloatingPointBase::type> {}; + struct IsFloatingPoint: __OctaIsFloatingPoint::type> {}; /* is array */ @@ -96,11 +97,11 @@ namespace octa { /* is pointer */ - template struct IsPointerBase : false_t {}; - template struct IsPointerBase: true_t {}; + template struct __OctaIsPointer : false_t {}; + template struct __OctaIsPointer: true_t {}; template - struct IsPointer: IsPointerBase::type> {}; + struct IsPointer: __OctaIsPointer::type> {}; /* is lvalue reference */ @@ -126,29 +127,25 @@ namespace octa { /* is function */ - template struct IsReference; + struct __OctaFunctionTestDummy {}; - namespace internal { - struct FunctionTestDummy {}; + template char __octa_function_test(T *); + template char __octa_function_test(__OctaFunctionTestDummy); + template int __octa_function_test(...); - template char function_test(T *); - template char function_test(FunctionTestDummy); - template int function_test(...); - - template T &function_source(int); - template FunctionTestDummy function_source(...); - } + template T &__octa_function_source(int); + template __OctaFunctionTestDummy __octa_function_source(...); template::value || IsUnion::value || IsVoid::value || IsReference::value || IsNullPointer::value - > struct IsFunctionBase: IntegralConstant(internal::function_source(0))) == 1 + > struct __OctaIsFunction: IntegralConstant(__octa_function_source(0))) == 1 > {}; - template struct IsFunctionBase: false_t {}; + template struct __OctaIsFunction: false_t {}; - template struct IsFunction: IsFunctionBase {}; + template struct IsFunction: __OctaIsFunction {}; /* is arithmetic */ @@ -170,38 +167,42 @@ namespace octa { /* is pointer to member */ - template struct IsMemberPointerBase: false_t {}; + template + struct __OctaIsMemberPointer: false_t {}; + template - struct IsMemberPointerBase: true_t {}; + struct __OctaIsMemberPointer: true_t {}; template - struct IsMemberPointer: IsMemberPointerBase< - typename RemoveConstVolatile::type + struct IsMemberPointer: __OctaIsMemberPointer< + typename RemoveCV::type > {}; /* is pointer to member object */ - template struct IsMemberObjectPointerBase: false_t {}; + template + struct __OctaIsMemberObjectPointer: false_t {}; template - struct IsMemberObjectPointerBase: IntegralConstant: IntegralConstant::value > {}; template struct IsMemberObjectPointer: - IsMemberObjectPointerBase::type> {}; + __OctaIsMemberObjectPointer::type> {}; /* is pointer to member function */ - template struct IsMemberFunctionPointerBase: false_t {}; + template + struct __OctaIsMemberFunctionPointer: false_t {}; template - struct IsMemberFunctionPointerBase: IntegralConstant: IntegralConstant::value > {}; template struct IsMemberFunctionPointer: - IsMemberFunctionPointerBase::type> {}; + __OctaIsMemberFunctionPointer::type> {}; /* is reference */ @@ -239,7 +240,8 @@ namespace octa { /* is empty */ - template struct IsEmpty: IntegralConstant {}; + template + struct IsEmpty: IntegralConstant {}; /* is POD */ @@ -252,16 +254,18 @@ namespace octa { /* is signed */ - template struct IsSigned: IntegralConstant {}; + template + struct IsSigned: IntegralConstant {}; /* is unsigned */ - template struct IsUnsigned: IntegralConstant {}; + template + struct IsUnsigned: IntegralConstant {}; /* is standard layout */ - template struct RemoveAllExtents; - template struct IsStandardLayout: IntegralConstant + struct IsStandardLayout: IntegralConstant::type>::value > {}; @@ -282,8 +286,6 @@ namespace octa { /* is trivial */ - template struct IsTriviallyDefaultConstructible; - template struct IsTrivial: IntegralConstant::value && IsTriviallyDefaultConstructible::value) @@ -292,15 +294,152 @@ namespace octa { /* has virtual destructor */ template - struct HasVirtualDestructor: IntegralConstant {}; + struct HasVirtualDestructor: IntegralConstant {}; - /* is destructible - libc++ used as ref */ + /* is constructible */ - template struct IsDestructibleApply { typedef int type; }; + template struct __OctaSelect2nd { typedef T type; }; + struct __OctaAny { __OctaAny(...); }; + + template typename __OctaSelect2nd< + decltype(octa::move(T(octa::declval()...))), true_t + >::type __octa_is_ctible_test(T &&, A &&...); + + template false_t __octa_is_ctible_test(__OctaAny, A &&...); + + template + struct __OctaCtibleCore: CommonType< + decltype(__octa_is_ctible_test(octa::declval(), + octa::declval()...)) + >::type {}; + + /* function types are not constructible */ + template + struct __OctaCtibleCore: false_t {}; + + /* scalars are default constructible, refs are not */ + template + struct __OctaCtibleCore: IsScalar {}; + + /* scalars and references are constructible from one arg if + * implicitly convertible to scalar or reference */ + template + struct __OctaCtibleRef { + static true_t test(T); + static false_t test(...); + }; + + template + struct __OctaCtibleCore: CommonType< + decltype(__OctaCtibleRef::test(octa::declval())) + >::type {}; + + /* scalars and references are not constructible from multiple args */ + template + struct __OctaCtibleCore: false_t {}; + + /* treat scalars and refs separately */ + template + struct __OctaCtibleVoidCheck: __OctaCtibleCore< + (IsScalar::value || IsReference::value), T, A... + > {}; + + /* if any of T or A is void, IsConstructible should be false */ + template + struct __OctaCtibleVoidCheck: false_t {}; + + template struct __OctaCtibleContainsVoid; + + template<> struct __OctaCtibleContainsVoid<>: false_t {}; + + template + struct __OctaCtibleContainsVoid { + static constexpr bool value = IsVoid::value + || __OctaCtibleContainsVoid::value; + }; + + /* entry point */ + template + struct __OctaCtible: __OctaCtibleVoidCheck< + __OctaCtibleContainsVoid::value || IsAbstract::value, + T, A... + > {}; + + /* array types are default constructible if their element type is */ + template + struct __OctaCtibleCore: __OctaCtible< + typename RemoveAllExtents::type + > {}; + + /* otherwise array types are not constructible by this syntax */ + template + struct __OctaCtibleCore: false_t {}; + + /* incomplete array types are not constructible */ + template + struct __OctaCtibleCore: false_t {}; + + template + struct IsConstructible: __OctaCtible {}; + + /* is default constructible */ + + template struct IsDefaultConstructible: IsConstructible {}; + + /* is copy constructible */ + + template struct IsCopyConstructible: IsConstructible::type>::type + > {}; + + /* is move constructible */ + + template struct IsMoveConstructible: IsConstructible::type + > {}; + + /* is assignable */ + + template typename __OctaSelect2nd< + decltype((octa::declval() = octa::declval())), true_t + >::type __octa_assign_test(T &&, U &&); + + template false_t __octa_assign_test(__OctaAny, T &&); + + template::value || IsVoid::value> + struct __OctaIsAssignable: CommonType< + decltype(__octa_assign_test(octa::declval(), octa::declval())) + >::type {}; + + template + struct __OctaIsAssignable: false_t {}; + + template + struct IsAssignable: __OctaIsAssignable {}; + + /* is copy assignable */ + + template struct IsCopyAssignable: IsAssignable< + typename AddLvalueReference::type, + typename AddLvalueReference::type>::type + > {}; + + /* is move assignable */ + + template struct IsMoveAssignable: IsAssignable< + typename AddLvalueReference::type, + const typename internal::AddRvalueReference::type + > {}; + + /* is destructible */ + + template struct __OctaIsDtibleApply { typedef int type; }; template struct IsDestructorWellformed { - template static char test(typename IsDestructibleApply< - decltype(declval().~TT()) + template static char test(typename __OctaIsDtibleApply< + decltype(octa::declval().~TT()) >::type); template static int test(...); @@ -308,25 +447,25 @@ namespace octa { static constexpr bool value = (sizeof(test(12)) == sizeof(char)); }; - template struct DestructibleImpl; + template struct __OctaDtibleImpl; template - struct DestructibleImpl: IntegralConstant: IntegralConstant::type>::value > {}; template - struct DestructibleImpl: true_t {}; + struct __OctaDtibleImpl: true_t {}; - template struct DestructibleFalse; + template struct __OctaDtibleFalse; - template struct DestructibleFalse - : DestructibleImpl::value> {}; + template struct __OctaDtibleFalse + : __OctaDtibleImpl::value> {}; - template struct DestructibleFalse: false_t {}; + template struct __OctaDtibleFalse: false_t {}; template - struct IsDestructible: DestructibleFalse::value> {}; + struct IsDestructible: __OctaDtibleFalse::value> {}; template struct IsDestructible: false_t {}; template< > struct IsDestructible: false_t {}; @@ -363,8 +502,6 @@ namespace octa { /* is trivially copy constructible */ - template struct AddLvalueReference; - template struct IsTriviallyCopyConstructible: IsTriviallyConstructible::type @@ -404,8 +541,6 @@ namespace octa { /* is trivially copy assignable */ - template struct AddLvalueReference; - template struct IsTriviallyCopyAssignable: IsTriviallyAssignable::type @@ -457,8 +592,6 @@ namespace octa { /* is nothrow copy constructible */ - template struct AddLvalueReference; - template struct IsNothrowCopyConstructible: IsNothrowConstructible::type @@ -498,8 +631,6 @@ namespace octa { /* is nothrow copy assignable */ - template struct AddLvalueReference; - template struct IsNothrowCopyAssignable: IsNothrowAssignable::type @@ -514,15 +645,15 @@ namespace octa { /* is nothrow destructible */ - template struct IsNothrowDestructibleBase; + template struct __OctaIsNothrowDtible; template - struct IsNothrowDestructibleBase: IntegralConstant().~T()) + struct __OctaIsNothrowDtible: IntegralConstant().~T()) > {}; template - struct IsNothrowDestructible: IsNothrowDestructibleBase::value > {}; @@ -544,15 +675,15 @@ namespace octa { template::value || IsFunction::value || IsArray::value - > struct IsConvertibleBase { + > struct __OctaIsConvertible { typedef typename IsVoid::type type; }; - template struct IsConvertibleBase { + template struct __OctaIsConvertible { template static void test_f(TT); template(declval())) + typename = decltype(test_f(octa::declval())) > static true_t test(int); template static false_t test(...); @@ -561,7 +692,7 @@ namespace octa { }; template - struct IsConvertible: IsConvertibleBase::type {}; + struct IsConvertible: __OctaIsConvertible::type {}; /* type equality */ @@ -604,7 +735,7 @@ namespace octa { template struct RemoveVolatile { typedef T type; }; template - struct RemoveConstVolatile { + struct RemoveCV { typedef typename RemoveVolatile::type>::type type; }; @@ -612,30 +743,30 @@ namespace octa { template::value || IsFunction::value || IsConst::value> - struct AddConstBase { typedef T type; }; + struct __OctaAddConst { typedef T type; }; - template struct AddConstBase { + template struct __OctaAddConst { typedef const T type; }; template struct AddConst { - typedef typename AddConstBase::type type; + typedef typename __OctaAddConst::type type; }; template::value || IsFunction::value || IsVolatile::value> - struct AddVolatileBase { typedef T type; }; + struct __OctaAddVolatile { typedef T type; }; - template struct AddVolatileBase { + template struct __OctaAddVolatile { typedef volatile T type; }; template struct AddVolatile { - typedef typename AddVolatileBase::type type; + typedef typename __OctaAddVolatile::type type; }; template - struct AddConstVolatile { + struct AddCV { typedef typename AddConst::type>::type type; }; @@ -703,141 +834,137 @@ namespace octa { * shamelessly copied from graphitemaster @ neothyne */ - namespace internal { - template struct TypeList { - typedef T first; - typedef U rest; - }; + template struct __OctaTL { + typedef T first; + typedef U rest; + }; - /* not a type */ - struct NAT { - NAT() = delete; - NAT(const NAT &) = delete; - NAT &operator=(const NAT &) = delete; - ~NAT() = delete; - }; + /* not a type */ + struct __OctaNAT { + __OctaNAT() = delete; + __OctaNAT(const __OctaNAT &) = delete; + __OctaNAT &operator=(const __OctaNAT &) = delete; + ~__OctaNAT() = delete; + }; - typedef TypeList>>>> stypes; + typedef __OctaTL>>>> stypes; - typedef TypeList>>>> utypes; + typedef __OctaTL>>>> utypes; - template - struct TypeFindFirst; + template + struct __OctaTypeFindFirst; - template - struct TypeFindFirst, N, true> { - typedef T type; - }; + template + struct __OctaTypeFindFirst<__OctaTL, N, true> { + typedef T type; + }; - template - struct TypeFindFirst, N, false> { - typedef typename TypeFindFirst::type type; - }; + template + struct __OctaTypeFindFirst<__OctaTL, N, false> { + typedef typename __OctaTypeFindFirst::type type; + }; - template::type>::value, - bool = IsVolatile::type>::value - > struct ApplyConstVolatile { - typedef U type; - }; + template::type>::value, + bool = IsVolatile::type>::value + > struct __OctaApplyCV { + typedef U type; + }; - template - struct ApplyConstVolatile { /* const */ - typedef const U type; - }; + template + struct __OctaApplyCV { /* const */ + typedef const U type; + }; - template - struct ApplyConstVolatile { /* volatile */ - typedef volatile U type; - }; + template + struct __OctaApplyCV { /* volatile */ + typedef volatile U type; + }; - template - struct ApplyConstVolatile { /* const volatile */ - typedef const volatile U type; - }; + template + struct __OctaApplyCV { /* const volatile */ + typedef const volatile U type; + }; - template - struct ApplyConstVolatile { /* const */ - typedef const U &type; - }; + template + struct __OctaApplyCV { /* const */ + typedef const U &type; + }; - template - struct ApplyConstVolatile { /* volatile */ - typedef volatile U &type; - }; + template + struct __OctaApplyCV { /* volatile */ + typedef volatile U &type; + }; - template - struct ApplyConstVolatile { /* const volatile */ - typedef const volatile U &type; - }; + template + struct __OctaApplyCV { /* const volatile */ + typedef const volatile U &type; + }; - template::value || IsEnum::value> - struct MakeSigned {}; + template::value || IsEnum::value> + struct __OctaMakeSigned {}; - template::value || IsEnum::value> - struct MakeUnsigned {}; + template::value || IsEnum::value> + struct __OctaMakeUnsigned {}; - template - struct MakeSigned { - typedef typename TypeFindFirst::type type; - }; + template + struct __OctaMakeSigned { + typedef typename __OctaTypeFindFirst::type type; + }; - template - struct MakeUnsigned { - typedef typename TypeFindFirst::type type; - }; + template + struct __OctaMakeUnsigned { + typedef typename __OctaTypeFindFirst::type 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 __OctaMakeSigned {}; + template<> struct __OctaMakeSigned { typedef schar type; }; + template<> struct __OctaMakeSigned { typedef schar type; }; + template<> struct __OctaMakeSigned { typedef short type; }; + template<> struct __OctaMakeSigned { typedef short type; }; + template<> struct __OctaMakeSigned { typedef int type; }; + template<> struct __OctaMakeSigned { typedef int type; }; + template<> struct __OctaMakeSigned { typedef long type; }; + template<> struct __OctaMakeSigned { typedef long type; }; + template<> struct __OctaMakeSigned { typedef llong type; }; + template<> struct __OctaMakeSigned { typedef llong type; }; - 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 __OctaMakeUnsigned {}; + template<> struct __OctaMakeUnsigned { typedef uchar type; }; + template<> struct __OctaMakeUnsigned { typedef uchar type; }; + template<> struct __OctaMakeUnsigned { typedef ushort type; }; + template<> struct __OctaMakeUnsigned { typedef ushort type; }; + template<> struct __OctaMakeUnsigned { typedef uint type; }; + template<> struct __OctaMakeUnsigned { typedef uint type; }; + template<> struct __OctaMakeUnsigned { typedef ulong type; }; + template<> struct __OctaMakeUnsigned { typedef ulong type; }; + template<> struct __OctaMakeUnsigned { typedef ullong type; }; + template<> struct __OctaMakeUnsigned { typedef ullong type; }; template struct MakeSigned { - typedef typename internal::ApplyConstVolatile::type + typedef typename __OctaApplyCV::type >::type >::type type; }; template struct MakeUnsigned { - typedef typename internal::ApplyConstVolatile::type + typedef typename __OctaApplyCV::type >::type >::type type; }; - /* common type */ - /* conditional */ template @@ -852,49 +979,48 @@ namespace octa { /* result of call at compile time */ - namespace internal { - template - inline auto result_of_invoke(F &&f, A &&...args) -> - decltype(forward(f)(forward(args)...)) { - return forward(f)(forward(args)...); - } - template - inline auto result_of_invoke(T B::*pmd, D &&ref) -> - decltype(forward(ref).*pmd) { - return forward(ref).*pmd; - } - template - inline auto result_of_invoke(PMD &&pmd, P &&ptr) -> - decltype((*forward

(ptr)).*forward(pmd)) { - return (*forward

(ptr)).*forward(pmd); - } - template - inline auto result_of_invoke(T B::*pmf, D &&ref, A &&...args) -> - decltype((forward(ref).*pmf)(forward(args)...)) { - return (forward(ref).*pmf)(forward(args)...); - } - template - inline auto result_of_invoke(PMF &&pmf, P &&ptr, A &&...args) -> - decltype(((*forward

(ptr)).*forward(pmf))(forward(args)...)) { - return ((*forward

(ptr)).*forward(pmf))(forward(args)...); - } - - template - struct ResultOf {}; - template - struct ResultOf(), - declval()...)))> { - using type = decltype(result_of_invoke(declval(), declval()...)); - }; + template + inline auto __octa_rof_invoke(F &&f, A &&...args) -> + decltype(forward(f)(forward(args)...)) { + return forward(f)(forward(args)...); + } + template + inline auto __octa_rof_invoke(T B::*pmd, D &&ref) -> + decltype(forward(ref).*pmd) { + return forward(ref).*pmd; + } + template + inline auto __octa_rof_invoke(PMD &&pmd, P &&ptr) -> + decltype((*forward

(ptr)).*forward(pmd)) { + return (*forward

(ptr)).*forward(pmd); + } + template + inline auto __octa_rof_invoke(T B::*pmf, D &&ref, A &&...args) -> + decltype((forward(ref).*pmf)(forward(args)...)) { + return (forward(ref).*pmf)(forward(args)...); + } + template + inline auto __octa_rof_invoke(PMF &&pmf, P &&ptr, A &&...args) -> + decltype(((*forward

(ptr)).*forward(pmf))(forward(args)...)) { + return ((*forward

(ptr)).*forward(pmf))(forward(args)...); } - template struct ResultOf: internal::ResultOf {}; + template + struct __OctaResultOf {}; + template + struct __OctaResultOf(), octa::declval()...)))> { + using type = decltype(__octa_rof_invoke(octa::declval(), + octa::declval()...)); + }; - /* enable_if */ + template struct ResultOf: __OctaResultOf {}; - template struct enable_if {}; + /* enable if */ - template struct enable_if { typedef T type; }; + template struct EnableIf {}; + + template struct EnableIf { typedef T type; }; /* decay */ @@ -907,7 +1033,7 @@ namespace octa { typename RemoveExtent::type *, typename Conditional::value, typename AddPointer::type, - typename RemoveConstVolatile::type + typename RemoveCV::type >::type >::type type; }; @@ -921,7 +1047,7 @@ namespace octa { }; template struct CommonType { - typedef Decay() : declval())> type; + typedef Decay() : octa::declval())> type; }; template @@ -931,17 +1057,15 @@ namespace octa { /* aligned storage */ - namespace internal { - template struct AlignedStorageTest { - union type { - uchar data[N]; - octa::max_align_t align; - }; + template struct __OctaAlignedTest { + union type { + uchar data[N]; + octa::max_align_t align; }; }; template::type) + = alignof(typename __OctaAlignedTest::type) > struct AlignedStorage { struct type { alignas(A) uchar data[N]; @@ -950,39 +1074,37 @@ namespace octa { /* aligned union */ - namespace internal { - template struct AlignMax; + template struct __OctaAlignMax; - template struct AlignMax { - static constexpr size_t value = N; - }; + template struct __OctaAlignMax { + static constexpr size_t value = N; + }; - template struct AlignMax { - static constexpr size_t value = (N1 > N2) ? N1 : N2; - }; + template struct __OctaAlignMax { + static constexpr size_t value = (N1 > N2) ? N1 : N2; + }; - template - struct AlignMax { - static constexpr size_t value - = AlignMax::value, N...>::value; - }; - } + template + struct __OctaAlignMax { + static constexpr size_t value + = __OctaAlignMax<__OctaAlignMax::value, N...>::value; + }; template struct AlignedUnion { static constexpr size_t alignment_value - = internal::AlignMax::value; + = __OctaAlignMax::value; struct type { - alignas(alignment_value) uchar data[internal::AlignMax::value]; }; }; /* underlying type */ - template::value> struct UnderlyingTypeBase; + template::value> struct __OctaUnderlyingType; - template struct UnderlyingTypeBase { + template struct __OctaUnderlyingType { typedef typename Conditional::value, typename MakeSigned::type, typename MakeUnsigned::type @@ -990,7 +1112,7 @@ namespace octa { }; template struct UnderlyingType { - typedef typename UnderlyingTypeBase::type type; + typedef typename __OctaUnderlyingType::type type; }; }