With the upcoming C++17 feature of non-type template arguments with auto, will it be possible to implement std::function
in such a way as to be able to put, for example, the following functions:
bool f(int n, double d) {}
bool g(bool b, char c) {}
bool h(bool b) {}
into auto-templated std::function
objects:
std::function<bool(auto, auto)> faa = f; // ok
std::function<bool(int, auto)> fia = f; // ok
std::function<bool(double, auto)> fda = f; // error: function type mismatch
std::function<bool(auto, auto)> gaa = g; // ok
std::function<bool(auto, auto)> haa = h; // error: function type mismatch
std::function<bool(auto)> ha = h; // ok
And so on.
In other words, to have std::function
objects constrained on the function types they accept?
(Currently, on GCC we get an error: 'auto' parameter not permitted in this context
.)