c++ - Determine the argument and result Type of a functor -


how can test whether functor callable object takes reference int , returns bool?

template<typename functor> void foo(functor f) {     static_assert('functor == bool (int&)', "error message");      int x = -1;     if (f(x))         std::cout << x << std::endl; }  bool bar(int& x) {     x = 4711;     return true; }  struct other {     bool operator()(int& x)     {         x = 815;         return true;     } }; 

looks me don't want check signature of functor, want restrict user can pass in, in first place:

if have access std::function can this:

void foo(const std::function<bool(int&)>& f) 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -