为何Boost callable_traits的is_invocable_v与is_invocable::value返回结果不同?
boost::callable_traits::is_invocable_v behaves differently from is_invocable::value in Boost 1.72? This inconsistency you're seeing is a known bug in Boost.CallableTraits 1.72.
In this version, the variable template boost::callable_traits::is_invocable_v was incorrectly implemented — it didn't properly reference the value member of the is_invocable trait. Instead, it likely pointed to an unrelated type or had a wrong definition, leading to the false (0) result while the underlying is_invocable<...>::value works correctly (matching std::is_invocable's behavior).
Solutions to fix this:
Define your own variable template as a workaround:
template<typename Func, typename... Args> constexpr bool boost_is_invocable_v = boost::callable_traits::is_invocable<Func, Args...>::value;You can use this custom
boost_is_invocable_vin place of the broken library-provided one.Upgrade your Boost version to 1.73 or later. This bug was fixed in subsequent releases of Boost.CallableTraits, so the
is_invocable_vvariable template will behave consistently with bothis_invocable::valueandstd::is_invocable_v.
To confirm, if you test your code with Boost 1.73+, you'll see all four outputs return 1 as expected.
内容的提问来源于stack exchange,提问作者maxbachmann

