Tests: sweep_allocator::construct() accepts pointers to const

Recent libc++ (emsdk latest) probes construct(const T*, const T&) in an
unevaluated context while checking for trivial copies; the static_cast to
void* in the noexcept specification then fails to compile.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N5NasEsrzHhSNouxSoEwqz
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels LohmannandClaude Sonnet 5.5 committed 2026-11-07 08:33:16 +00:00
1 parent 439bbf9236
commit f0cbfa5bb0
1 file changed
+4 -2
+4 -2
View File
@@ -1073,10 +1073,12 @@ struct sweep_allocator
return (std::numeric_limits<std::size_t>::max)() / sizeof(T); return (std::numeric_limits<std::size_t>::max)() / sizeof(T);
} }
// p may point to a const object when libc++ probes whether construct() is
// usable for copying, which static_cast<void*>(p) would not accept
template<class U, class... Args> template<class U, class... Args>
void construct(U* p, Args&& ... args) noexcept(noexcept(::new (static_cast<void*>(p)) U(std::forward<Args>(args)...))) void construct(U* p, Args&& ... args) noexcept(noexcept(::new (const_cast<void*>(static_cast<const volatile void*>(p))) U(std::forward<Args>(args)...)))
{ {
::new (static_cast<void*>(p)) U(std::forward<Args>(args)...); ::new (const_cast<void*>(static_cast<const volatile void*>(p))) U(std::forward<Args>(args)...);
} }
template<class U> template<class U>