How to check if template argument is a callable with a given signature

后端 未结 5 1897
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 16:58

Basically, what I want to achieve is compile-time verification (with possibly nice error message) that registered callable (either a function, a lambda, a struct with call o

5条回答
  •  佛祖请我去吃肉
    2020-12-14 17:16

    You can use std::is_convertible (since C++11), e.g.

    static_assert(std::is_convertible_v>, "Wrong Signature!");
    

    or

    static_assert(std::is_convertible_v, "Wrong Signature!");
    

    LIVE

提交回复
热议问题