C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Derived class's function invokes base class's function

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 16 Apr 2022 00:11:42 +0100
On 4/15/22, Jens Maurer wrote:

> Let me make a rather bold prediction: this proposal won't go anywhere
> unless you show convincing use-cases with "before" and "after" code
> snippets <snip>



In draft No.3 of my proposal, I'll give more examples of alternative solutions.



> so that "Maybe these new continuity methods [...] will catch
> up too" turns into "These new continuity methods are so attractive we
> should have put them into the standard a decade ago" for a large
> majority of WG21 participants.
>
> P0847R7 "Deducing this" was such a proposal.
>
> The one we have here still needs substantial homework.



Right now I'm spending time writing my 'pre-compiler' that will act as
an intermediary between the preprocessor and the compiler, so that
people will be able to try out continuity methods before they're ever
implemented properly in any compiler. I've already coded the 'first
pass' which enumerates all the namespaces and classes in the
translation unit. So the 'second pass' will create, for each derived
class, a tree containing all its base classes. The final operation of
the pre-compiler will be to turn a function like:

int Func(void) continue
{
    return 5;
}

into:

void Func(void)
{
    this->Base1::Func();
    this->Base2::Func();

    return 5;
}

And then the translation unit can be fed into a real c++20 compiler.
I'll pipe it as a one-liner:

g++ -std=c++20 -E -P main.cpp -o - | precompiler | g++ -std=c++20 -o
main.o -x c++ -c -

Received on 2022-04-15 23:11:44