C++ std::是否可以在C++;11?

C++ std::是否可以在C++;11?,c++,c++11,c++17,C++,C++11,C++17,我想使用std::is_invocable,但是我们使用的是c++11标准,而is_invocable只能从c++17获得 是否有任何方法可以使用c++11模拟该功能 谢谢 你可以尝试这个实现:从Boost C++库中获取。我已经用VS2017和标准C++14对其进行了测试 template <typename F, typename... Args> struct is_invocable : std::is_constructible< std::f

我想使用std::is_invocable,但是我们使用的是c++11标准,而is_invocable只能从c++17获得

是否有任何方法可以使用c++11模拟该功能


谢谢

你可以尝试这个实现:从Boost C++库中获取。我已经用VS2017和标准C++14对其进行了测试

template <typename F, typename... Args>
struct is_invocable :
    std::is_constructible<
        std::function<void(Args ...)>,
        std::reference_wrapper<typename std::remove_reference<F>::type>
    >
{
};

template <typename R, typename F, typename... Args>
struct is_invocable_r :
    std::is_constructible<
        std::function<R(Args ...)>,
        std::reference_wrapper<typename std::remove_reference<F>::type>
    >
{
};
模板
结构是可调用的:
std::是可构造的吗<
std::函数,
标准::参考包装器
>
{
};
模板
结构是可开票的:
std::是可构造的吗<
std::函数,
标准::参考包装器
>
{
};

在C++中,C++中有一个等价的例子。你尝试过<代码> STD::y-iSyAccosiabd< /Cord>?你检查Boost库,@ RoN-<代码> STD:Y-IsIsAccosiabd//Cord>不是C++ 11的一部分,也不是C++版本的其他版本。它看起来像是特定库实现的内部细节。@PeteBecker我明白了。该评论表明,它在某种程度上与C++11相当。或者这是我的理解,它需要库来实现。