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 (cherry picked from commit 794bf70823c12a2a1cb2a8a95f34dfb6357746a8) Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 file changed
+4
-2
@@ -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>
|
||||||
|
|||||||
Reference in new issue
Block a user