C++ Logo


Advanced search

Re: [std-proposals] Versatility -- Classes change at runtime

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sun, 31 Jul 2022 11:03:23 +0100
On Sun, Jul 31, 2022 at 5:43 AM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> > Start with a new syntax, because right now the vtables are in read-only
> > memory. You must somehow signal the compiler that they should be modifiable.
> To be clear: you must signal in code.
> Compiler options are out of scope in this list. If you just want a compiler
> extension, make a suggestion to the implementations you care about.

Well then we should discuss whether this should change.

Perhaps a very limited number of compiler options should be part of
the C++ standard. Freedom of syntax could abide the following regex:


The 1st capture group is the name of the option, and the 2nd capture
group is what you've set it to. See this regex in action with examples


This regex accepts the following three syntaxes:


If you're willing to suffer the overhead of having all classes be
polymorphic then do this:


And if you want to turn the feature off completely then do:


These command line options are accumulative from left to right, so if you do:


then it's the same as doing:


However if you use "+" to turn it on fully, or if you use "-" to turn
it off fully, then these two options wipe out the previous one's. So
for example if you do:

        my_favourite_compiler --cplusplus_polymorphic_class=+

Then it's the same as doing:

        my_favourite_compiler --cplusplus_polymorphic_class=-

So maybe we should have compiler options in future C++ standards to
achieve higher levels of versatility.

By the way, C++ programmers writing code today in 2022 have to use
some compiler options to get their standard-compliant code to compile.
For example if I want to use "std::thread" in the GNU compiler (g++)
then I have to compile with "-pthread".

Received on 2022-07-31 10:03:33