Description
From the discussion here: #2395
The combination of cv-qualifiers with callback overloads results in a large number of overloads to match all possible types that could be passed to the Callback class.
This isn't a big problem for void (*)(cv T *)
function types, but for void (T::*)() cv
types, the method in which cv-qualifiers are associated prevents encoding the cv-qualifiers in the T
type, and requiring a large combination of overloads for all cv-qualifiers.
From the discussion:
There is no elegant fix here:
- Function pointer overload can be cast at user side
- Just accept callback as the function parameter, it force the user to write
ticker.attach(Callback<void()>(&t, &Thing::doit), 1.0f /* delay */)
. For non overladed function member it is even possible to provide an equivalent to bind:ticker.attach(make_callback(&t, &Thing::doit), 1.0f)
. This is I believe the best solution once, it will always work with everything when member function cv qualifiers will be correctly handled by theCallback
class.- Provide any overload possible, it doesn't work for cv member functions at this stage and increase the maintenance effort while easing the usage.
It seems like the best way forward is to deprecate the convenience overloads in the ticker class and move to just accepting a single Callback type, perhaps providing a convenience callback
function as @pan- suggests. In this case we should deprecate (not remove yet) the non-cv-qualified overloads.