C++ Logo


Advanced search

Re: [std-proposals] Detect non overriden function

From: organicoman <organicoman_at_[hidden]>
Date: Mon, 21 Mar 2022 14:56:28 +0400
Hello,You are a genius, you almost hit the target."deprecated" simulates what i want to achieve.1- allow the function to be called2- issue a warningA 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. NadSent from my Galaxy
-------- Original message --------From: Magnus Fromreide <magfr_at_[hidden]> Date: 3/21/22 1:23 PM (GMT+04:00) To: organicoman via Std-Proposals <std-proposals_at_[hidden]> Cc: organicoman <organicoman_at_[hidden]> Subject: Re: [std-proposals] Detect non overriden function Hello.You have not been very clear about how you want your new warning to workbut 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?

Received on 2022-03-21 10:56:40