Workaround Clang <3.6 apply_r() runtime failure
Lambdas with certain noexcept specifiers are deemed non-invocable at compile-time, failing at runtime.
This commit is contained in:
parent
6e1056dd53
commit
f8ddc20d5c
@ -5397,7 +5397,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
R apply_r(Fn&& f, Args&& ... args)
|
R apply_r(Fn&& f, Args&& ... args)
|
||||||
{
|
{
|
||||||
R out;
|
R out;
|
||||||
apply_cb([&out](R && r) noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
// dynamic noexcept specifier fails to compile on Clang <3.6
|
||||||
|
apply_cb([&out](R && r)
|
||||||
|
#if !defined(__clang__) || (defined(__clang__) && __clang_major__ == 3 && __clang_minor__ > 5)
|
||||||
|
noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
out = std::forward<decltype(r)>(r);
|
out = std::forward<decltype(r)>(r);
|
||||||
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
||||||
@ -5408,7 +5412,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
R apply_r(Fn&& f, Args&& ... args) const
|
R apply_r(Fn&& f, Args&& ... args) const
|
||||||
{
|
{
|
||||||
R out;
|
R out;
|
||||||
apply_cb([&out](R && r) noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
// dynamic noexcept specifier fails to compile on Clang <3.6
|
||||||
|
apply_cb([&out](R && r)
|
||||||
|
#if !defined(__clang__) || (defined(__clang__) && __clang_major__ == 3 && __clang_minor__ > 5)
|
||||||
|
noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
out = std::forward<decltype(r)>(r);
|
out = std::forward<decltype(r)>(r);
|
||||||
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
||||||
|
|||||||
@ -23777,7 +23777,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
R apply_r(Fn&& f, Args&& ... args)
|
R apply_r(Fn&& f, Args&& ... args)
|
||||||
{
|
{
|
||||||
R out;
|
R out;
|
||||||
apply_cb([&out](R && r) noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
// dynamic noexcept specifier fails to compile on Clang <3.6
|
||||||
|
apply_cb([&out](R && r)
|
||||||
|
#if !defined(__clang__) || (defined(__clang__) && __clang_major__ == 3 && __clang_minor__ > 5)
|
||||||
|
noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
out = std::forward<decltype(r)>(r);
|
out = std::forward<decltype(r)>(r);
|
||||||
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
||||||
@ -23788,7 +23792,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
R apply_r(Fn&& f, Args&& ... args) const
|
R apply_r(Fn&& f, Args&& ... args) const
|
||||||
{
|
{
|
||||||
R out;
|
R out;
|
||||||
apply_cb([&out](R && r) noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
// dynamic noexcept specifier fails to compile on Clang <3.6
|
||||||
|
apply_cb([&out](R && r)
|
||||||
|
#if !defined(__clang__) || (defined(__clang__) && __clang_major__ == 3 && __clang_minor__ > 5)
|
||||||
|
noexcept(noexcept(out = std::forward<decltype(r)>(r)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
out = std::forward<decltype(r)>(r);
|
out = std::forward<decltype(r)>(r);
|
||||||
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
}, std::forward<Fn>(f), std::forward<Args>(args)...);
|
||||||
|
|||||||
@ -336,10 +336,6 @@ TEST_CASE("apply*() functions")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply_cb() (which apply_r() is based on) fails on Clang
|
|
||||||
// due to is_invocable not yielding true as expected
|
|
||||||
// while testing the invocable implementation Clang 3.5 crashed
|
|
||||||
#if !defined(__clang__) || (defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 6)
|
|
||||||
SECTION("apply_r()")
|
SECTION("apply_r()")
|
||||||
{
|
{
|
||||||
SECTION("value types")
|
SECTION("value types")
|
||||||
@ -653,6 +649,8 @@ TEST_CASE("apply*() functions")
|
|||||||
CHECK(f.bar == 42);
|
CHECK(f.bar == 42);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add functor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user