Hello,
You are a genius, you almost hit the target.
"deprecated" simulates what i want to achieve.
1- allow the function to be called
2- issue a warning
A couple of drawbacks are:
- it is still triggered when called on the base class instances.(which is not desired)
- all other derived classes will trigger the warning even if they don't subscribe to it.
- it doesn't differentiate between overriden members, and hidden member functions(non virtual)
I guess i found a way to simulate this warning, using clazy, static analyzer, i just need to find a way to add it to its rules list.
Thanks tho, it was brilliant idea.
Nad
-------- Original message --------
From: Magnus Fromreide <magfr@lysator.liu.se>
Date: 3/21/22 1:23 PM (GMT+04:00)
To: organicoman via Std-Proposals <std-proposals@lists.isocpp.org>
Cc: organicoman <organicoman@yahoo.fr>
Subject: Re: [std-proposals] Detect non overriden function
Hello.
You have not been very clear about how you want your new warning to work
but given the example you provided:
class base {
virtual void foo() {}
};
class derived: public base {
[non_overriden] base::foo; //will warn when called
};
I have to ask if
class derived: public base {
[[deprecated("Warn when called")]] void foo() { base::foo(); }
};
does what you want?