C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Not quite a template virtual function

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 2 Oct 2024 10:44:23 +0100
I reply to Robin and Lénárd:


Robin wrote:
>
> That example is potentially ODR breaking as you could have
> different compilation units that see different "SomeGlobalFunction":s

Lénárd wrote;
>
> Even seeing the same functions in different order would be potentially ODR-breaking.


This can be alleviated by restricting it even further. Previously I wrote:

 "A class shall not have a non-static virtual method with the
parameter list "auto&&... args" unless the inline body of the method
contains an invocation of a non-template-and-non-variadic function
with the arguments "static_cast<decltype(args)>(args)..." -- in which
case the virtual method will be given an instantiation for each of the
overload signatures of the aforementioned
non-template-and-non-variadic function."

But we can change "non-template-and-non-variadic function" to
"non-template-and-non-variadic member function". Since you can only
have one definition of a class, there won't be any case of one
translation unit seeing member functions that another translation unit
doesn't see -- nor any case of seeing them in a different order.

Received on 2024-10-02 09:44:36