I have a class like this:
class MyCallbacks
{
protected:
[[deprecated]] virtual void callback(int, int, const std::string &, double, int) {}
virtual void callback(const Context & t_context)
{
// default implementation calls the old version
callback(t_context.id, t_context.level, t_context.name, t_context.weight, t_context.specifics;
}
}
This lets existing code live in peace while giving the option to get the newer, better version of the callback that has richer data.
However, if someone accidentally overrode both versions of the method that would be bad. I’d like to get a deprecation warning when overriding the deprecated callback, but at least in gcc and clang this doesn’t seem to be covered by [[deprecated]]
.
Is there any way to do this, either with another attribute or via some clever trick?
1