boostorg / callable_traits

modern C++ type traits and metafunctions for callable types
Boost Software License 1.0
130 stars 36 forks source link

is_invocable_v is broken #184

Closed eugnsp closed 4 years ago

eugnsp commented 4 years ago

It seems that is_invocable_v variable template is broken. is_invocable and is_invocable_v have different implementations:

template<typename T, typename... Args>
struct is_invocable : detail::is_invocable_impl<T, Args...>::type {
    using type = typename detail::is_invocable_impl<T, Args...>::type;
};

template<typename T, typename... Args>
constexpr bool is_invocable_v =
    detail::is_invocable_impl<detail::traits<T>, Args...>::type::value;

With my understanding, it is not detail::traits<T> that should be checked for invocability, but simply T. As a result, this assertion fails:

#include <boost/callable_traits.hpp>

int test(int) { return 0; }

static_assert(
    boost::callable_traits::is_invocable_v<decltype(test), int> == 
    boost::callable_traits::is_invocable<decltype(test), int>::value
);

Originally reported here: https://stackoverflow.com/q/61696567

badair commented 4 years ago

Thanks for the bug report, this is gross. Will fix for Boost 1.74 as well as the missing test coverage.

badair commented 4 years ago

Fixed via #185