This improves the diagnostics when instantiating member functions with types that don't meet the preconditions. For example, this error message now gets produced when instantiating resize() with a type that's not copy constructible:
In file included from erros.cpp:1: /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/vector:1886:5: error: static assertion failed due to requirement '__is_cpp17_copy_insertable<std::allocator<NotCopyInsertable>>::value': value_type has to be Cpp17CopyInsertable static_assert(__is_cpp17_copy_insertable<_Allocator>::value, "value_type has to be Cpp17CopyInsertable"); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ erros.cpp:10:5: note: in instantiation of member function 'std::vector<NotCopyInsertable>::resize' requested here v.resize(1, NotCopyInsertable(1)); ^ In file included from erros.cpp:1: In file included from /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/vector:299: In file included from /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/__split_buffer:21: /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/__memory/allocator.h:165:28: error: call to implicitly-deleted copy constructor of 'NotCopyInsertable' ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/__memory/allocator_traits.h:292:13: note: in instantiation of function template specialization 'std::allocator<NotCopyInsertable>::construct<NotCopyInsertable, const NotCopyInsertable &>' requested here __a.construct(__p, _VSTD::forward<_Args>(__args)...); ^ /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/vector:1000:25: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<NotCopyInsertable>>::construct<NotCopyInsertable, const NotCopyInsertable &, void>' requested here __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x); ^ /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/vector:1043:15: note: in instantiation of member function 'std::vector<NotCopyInsertable>::__construct_at_end' requested here this->__construct_at_end(__n, __x); ^ /home/nikolas/llvm-projects/libcxx/build/include/c++/v1/vector:1889:15: note: in instantiation of member function 'std::vector<NotCopyInsertable>::__append' requested here this->__append(__sz - __cs, __x); ^ erros.cpp:10:5: note: in instantiation of member function 'std::vector<NotCopyInsertable>::resize' requested here v.resize(1, NotCopyInsertable(1)); ^ erros.cpp:5:3: note: copy constructor is implicitly deleted because 'NotCopyInsertable' has a user-declared move constructor NotCopyInsertable(NotCopyInsertable&&); ^ 2 errors generated.
Clangd emits the first error with this patch and the second error without.
Let's add a comment like:
// Implement named requirements from http://eel.is/c++draft/container.alloc.reqmts
And then, while we're at it, we should also implement Cpp17EmplaceConstructible and other named requirements, and probably check them in the places where they are mandated.