mirror of
https://github.com/nlohmann/json.git
synced 2026-11-07 13:09:21 +00:00
Fix ci_emscripten: make sweep_allocator::construct() not viable for const types (#6036)
* Tests: make sweep_allocator::construct() not viable for const types The newest libc++ (emsdk latest, used by ci_emscripten) probes construct(const T*, const T&) in an unevaluated context while checking whether copies are trivial. For the test allocator, instantiating the noexcept specification then fails to compile, because static_cast<void*> cannot drop the const qualifier. Constrain construct() to non-const types, which makes the probe fail in the SFINAE context instead of with a hard error. 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> * Fix CI: astyle and clang-tidy for sweep_allocator::construct() astyle 3.4.13 reformats the enable_if<!...> default template argument (Check amalgamation). Delete the const overload instead, which makes the libc++ probe for const objects fail in the SFINAE context just the same and needs no <type_traits>. 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> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b54267d2a7
commit
cbb9e14889
1 file changed
+5
@@ -1079,6 +1079,11 @@ struct sweep_allocator
|
||||
::new (static_cast<void*>(p)) U(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// libc++ probes whether construct() is usable for const objects (when
|
||||
// checking for trivial copies); this must not be viable then
|
||||
template<class U, class... Args>
|
||||
void construct(const U* /*unused*/, const Args& ... /*unused*/) = delete;
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p) noexcept
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user