Description
I was trying to use std::uninitialized_construct_using_allocator
which was recently added in libc++, but one of the uses I had failed to compile. The actual problem is with std::uses_allocator_construction_args
, so I'll put a simplified example using that instead.
void test()
{
using vt = std::pair<std::pmr::string, std::pair<std::pmr::string, std::pmr::string>>;
std::pmr::polymorphic_allocator<vt> alloc;
std::uses_allocator_construction_args<vt>(alloc, std::piecewise_construct,
std::forward_as_tuple("foo"),
std::forward_as_tuple("bar", "baz"));
}
This works with libstdc++ but fails to compile with libc++. After digging for a while, I found out the problem is that __uses_allocator_construction_args
overloads are not forward-declared. In particular,
llvm-project/libcxx/include/__memory/uses_allocator_construction.h
Lines 55 to 57 in c6472f5
is declared before
llvm-project/libcxx/include/__memory/uses_allocator_construction.h
Lines 79 to 81 in c6472f5
which is why the instantiation of the first one fails (as it can't find the second declaration).
Godbolt repro: https://godbolt.org/z/WorEzejxW
I'd appreciate a fix. Thanks!
Note: this might be related to #64466