diff --git a/octa/memory.hh b/octa/memory.hh index 9e447ea..9f07d8e 100644 --- a/octa/memory.hh +++ b/octa/memory.hh @@ -1068,10 +1068,51 @@ inline AllocatorType allocator_container_copy(const A &a) { >(), a); } +/* allocator arg */ + struct AllocatorArg {}; constexpr AllocatorArg allocator_arg = AllocatorArg(); +/* uses allocator */ + +namespace detail { + template struct HasAllocatorType { + template static char test(typename U::Allocator *); + template static int test(...); + static constexpr bool value = (sizeof(test(0)) == 1); + }; + + template::value> + struct UsesAllocatorBase: IntegralConstant::value + > {}; + + template + struct UsesAllocatorBase: False {}; +} + +template +struct UsesAllocator: detail::UsesAllocatorBase {}; + +/* uses allocator ctor */ + +namespace detail { + template + struct UsesAllocCtor { + static constexpr bool ua = UsesAllocator::value; + static constexpr bool ic = IsConstructible< + T, AllocatorArg, A, Args... + >::value; + static constexpr int value = ua ? (2 - ic) : 0; + }; +} + +template +struct UsesAllocatorConstructor: IntegralConstant::value +> {}; + } /* namespace octa */ #endif \ No newline at end of file