C++ Logo

std-proposals

Advanced search

Re: Partial type definition

From: Valery Osheter <valery.o_at_[hidden]>
Date: Tue, 24 Aug 2021 08:00:16 +0300
I just want the compuler knows that my class has some public methods before
I define whole class structure. The same is right for deduced this as well.
The method of partial declaration I proposed uses extern keyword without
variable declaration. If you think this method leads to misuse and errors,
I can propose an alternative:

struct worker;
void worker::work();

On Tue, Aug 24, 2021, 00:09 Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Sunday, 22 August 2021 05:27:12 PDT Valery Osheter via Std-Proposals
> wrote:
> > The compiler allows the forward declaration of a type name only. The type
> > name then can be used as a reference or a pointer only. If we want to
> call
> > a method of this type, a complete type definition is required. I
> understand
> > that this requirement comes from the storage details. But this compiler's
> > restriction is unnecessery for static and non-virtual methods, and other
> > things that are not related to the instance data.
>
> Before we go further, please make sure that your request takes
> https://wg21.link/p0847 into consideration: in a C++ world with deduced
> this,
> do we need extern struct?
>
> Also, mind you,
>
> extern struct worker
> {
> void work();
> };
>
> and
>
> extern struct worker
> {
> void work();
> } s;
>
> Have VERY different meanings.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DPG Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2021-08-24 00:00:34