diff --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h --- a/libcxx/include/__memory/allocator.h +++ b/libcxx/include/__memory/allocator.h @@ -27,7 +27,7 @@ template class allocator; -#if _LIBCPP_STD_VER <= 17 +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) template <> class _LIBCPP_TEMPLATE_VIS allocator { diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator_types.void.compile.cxx20_with_removed_members.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.void.compile.cxx20_with_removed_members.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.void.compile.cxx20_with_removed_members.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Check that the nested types of std::allocator are provided in C++20 +// with a flag that keeps the removed members. + +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS + +#include +#include + +int main() { + static_assert((std::is_same::pointer, void*>::value), ""); + static_assert((std::is_same::const_pointer, const void*>::value), ""); + static_assert((std::is_same::value_type, void>::value), ""); + static_assert((std::is_same::rebind::other, std::allocator >::value), ""); +}