C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Detect non overriden function

From: organicoman <organicoman_at_[hidden]>
Date: Sat, 19 Mar 2022 17:56:25 +0400
> Hello,> Is there a way to decorate a member function as non overriden, so at the call site the user will receive a compile time warning that he is using the base class implementation instead of the derived class implementation?If your intent is to force derived classes to override a method, andyou want to give a compile error when attempting to call this functionif the derived class did not, we already have a mechanism for that:pure virtual functions.No, actually the contrary. If that won't solve the issue, you should explain what functionalitypure virtual functions lack that you're looking for.Expl:struct base{ virtual void foo(){};};struct derived: public base{}int main(){ derived d; d.foo(); // i would like to receive a warning here telling me that I'm using the base class implementation }Sent from my Galaxy
-------- Original message --------From: Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> Date: 3/19/22 5:41 PM (GMT+04:00) To: std-proposals_at_[hidden] Cc: Jason McKesson <jmckesson_at_[hidden]> Subject: Re: [std-proposals] Detect non overriden function On Sat, Mar 19, 2022 at 7:35 AM organicoman via Std-Proposals<std-proposals_at_[hidden]> wrote:>> Hello,> Is there a way to decorate a member function as non overriden, so at the call site the user will receive a compile time warning that he is using the base class implementation instead of the derived class implementation?If your intent is to force derived classes to override a method, andyou want to give a compile error when attempting to call this functionif the derived class did not, we already have a mechanism for that:pure virtual functions.If that won't solve the issue, you should explain what functionalitypure virtual functions lack that you're looking for.-- Std-Proposals mailing listStd-Proposals_at_[hidden]://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2022-03-19 13:56:33