diff --git a/include/memory b/include/memory index d6b427b94..56502e2a1 100644 --- a/include/memory +++ b/include/memory @@ -5597,6 +5597,16 @@ struct __temp_value { }; #endif +#if _LIBCPP_STD_VER > 14 +template +struct __is_allocator : false_type {}; + +template +struct __is_allocator<_Alloc, + void_t().allocate(size_t{}))>> + : true_type {}; +#endif + _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS diff --git a/test/libcxx/memory/is_allocator.pass.cpp b/test/libcxx/memory/is_allocator.pass.cpp new file mode 100644 index 000000000..c33b7e829 --- /dev/null +++ b/test/libcxx/memory/is_allocator.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// struct __is_allocator; + +// Is either true_type or false_type depending on if A is an allocator. + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" +#include "test_allocator.h" + +template +void test_allocators() +{ + static_assert( std::__is_allocator>::value, "" ); + static_assert( std::__is_allocator>::value, "" ); + static_assert( std::__is_allocator>::value, "" ); +} + + +int main() +{ +// test_allocators(); + test_allocators(); + test_allocators(); + test_allocators(); +}