On 19 fev, 10:59, Thomas Lehmann <t.lehm...@rtsgroup.net> wrote:
2) Meta programming. I just want to know wether two types
are the same or not!
Unfortunately that's not what I really meant by using two functions
interchangeably. If you make a string comparison of, say, void(*)
(double) and int(*)(int), your metafunction will say that they're
(rightfully) different. But say I have:
int test(int a) { return a; }
std::function<void(double>> f = a;
It is valid and compiles, although the function signatures are
different. I want a metafunction that tells me whether we can set a
particular std::function to another function which signatures are
different, but 'compatible', as is in this case.
My real issue is with function overloading. Suppose I have two
functions:
void func(std::function<void(int)> f) {}
void func(std::function<void(int,int)> f) {}
The correct overload would only be resolved if the parameter I'm
passing is a std::function with the correct signature. If I pass, for
instance, a 'int test(int) {}' pointer to func, instead of resolving
to the first overload, the compiler will say the call is ambiguous. I
want to disambiguate this by using SFINAE, by removing the unwanted
overload from the overload set.
arbitrary function object qualifies. Consider:
[ comp.lang.c++.moderated. First time posters: Do this! ]