diff --git a/octa/memory.h b/octa/memory.h index 818f609..7e52278 100644 --- a/octa/memory.h +++ b/octa/memory.h @@ -76,65 +76,103 @@ namespace octa { }; template::value> - struct __OctaPtrTraitsRebind { + struct __OctaPtrTraitsRebindType { typedef typename T::template rebind type; }; template class T, typename U, typename ...A, typename V > - struct __OctaPtrTraitsRebind, V, true> { + struct __OctaPtrTraitsRebindType, V, true> { typedef typename T::template rebind type; }; template class T, typename U, typename ...A, typename V > - struct __OctaPtrTraitsRebind, V, false> { + struct __OctaPtrTraitsRebindType, V, false> { typedef T type; }; template - struct PointerTraits { - typedef T pointer; + struct __OctaPtrTraitsPointer { + typedef T type; + }; - typedef typename __OctaPtrTraitsElementType ::type element_type; - typedef typename __OctaPtrTraitsDifferenceType::type difference_type; + template + struct __OctaPtrTraitsPointer { + typedef T *type; + }; - template - using rebind = typename __OctaPtrTraitsRebind::type; + template + using PointerType = typename __OctaPtrTraitsPointer::type; - private: - struct __OctaNat {}; + template + struct __OctaPtrTraitsElement { + typedef typename __OctaPtrTraitsElementType::type type; + }; - public: - static T pointer_to(Conditional::value, - __OctaNat, element_type + template + struct __OctaPtrTraitsElement { + typedef T type; + }; + + template + using PointerElement = typename __OctaPtrTraitsElement::type; + + template + struct __OctaPtrTraitsDifference { + typedef typename __OctaPtrTraitsDifferenceType::type type; + }; + + + template + struct __OctaPtrTraitsDifference { + typedef ptrdiff_t difference_type; + }; + + template + using PointerDifference = typename __OctaPtrTraitsDifference::type; + + template + struct __OctaPtrTraitsRebind { + using type = typename __OctaPtrTraitsRebindType::type; + }; + + template + struct __OctaPtrTraitsRebind { + using type = U *; + }; + + template + using PointerRebind = typename __OctaPtrTraitsRebind::type; + + struct __OctaPtrTraitsNat {}; + + template + struct __OctaPtrTraitsPointerTo { + static T pointer_to(Conditional>::value, + __OctaPtrTraitsNat, PointerElement > &r) noexcept(noexcept(T::pointer_to(r))) { return T::pointer_to(r); } }; template - struct PointerTraits { - typedef T *pointer; - typedef T element_type; - - typedef ptrdiff_t difference_type; - - template using rebind = U *; - - private: - struct __OctaNat {}; - - public: - static T pointer_to(Conditional::value, - __OctaNat, element_type - > &r) noexcept { + struct __OctaPtrTraitsPointerTo { + static T pointer_to(Conditional::value, __OctaPtrTraitsNat, T> &r) + noexcept { return octa::address_of(r); } }; + template + static T pointer_to(Conditional>::value, + __OctaPtrTraitsNat, PointerElement + > &r) noexcept(noexcept(__OctaPtrTraitsPointerTo::pointer_to(r))) { + return __OctaPtrTraitsPointerTo::pointer_to(r); + } + /* default deleter */ template @@ -326,8 +364,8 @@ namespace octa { }; template::element_type>, - RemoveCv::element_type> + RemoveCv>, + RemoveCv> >::value> struct __OctaSameOrLessCvQualifiedBase: IsConvertible {}; template