可以在C 11中模拟std :: is_invocable吗?
发布时间:2020-12-16 03:42:19 所属栏目:百科 来源:网络整理
导读:我想使用std :: is_invocable,但是我们使用的是c 11标准,而is_invocable只能从c 17开始使用. 有没有办法用c 11模拟功能? 谢谢 解决方法 你可以尝试这个实现:)取自boost C库.我用VS2017用标准C 14测试了它. template typename F,typename... Argsstruct is_i
我想使用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> > { }; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |