Home How to check if template argument is a callable with a given signature
Reply: 0

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

user560
1#
user560 Published in April 27, 2018, 6:53 am

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 operator) has correct signature. Example (contents of the static_assert are to be filled):

struct A {
  using Signature = void(int, double);

  template <typename Callable>
  void Register(Callable &&callable) {
    static_assert(/* ... */);
    callback = callable;
  }

  std::function<Signature> callback;
};
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.262078 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO