Can std::is_invocable be emulated within C++11?

后端 未结 1 1743
粉色の甜心
粉色の甜心 2020-12-11 02:48

I\'d like to use std::is_invocable, however we are using c++11 standard, while is_invocable is available only from c++17.

Is there any way to emulate the functionali

1条回答
  •  感情败类
    2020-12-11 03:16

    You can try this implementation:) Taken from boost C++ libraries. I've tested it with VS2017 with standard C++14.

    template 
    struct is_invocable :
        std::is_constructible<
            std::function,
            std::reference_wrapper::type>
        >
    {
    };
    
    template 
    struct is_invocable_r :
        std::is_constructible<
            std::function,
            std::reference_wrapper::type>
        >
    {
    };
    

    0 讨论(0)
提交回复
热议问题