Date: Mon, 30 Dec 2024 17:09:52 +0300
That's not that i'm an expert, but i think it might be useful, but i think
yes, it will be hard to add to the language.
пн, 30 дек. 2024 г. в 16:44, Phil Endecott via Std-Proposals <
std-proposals_at_[hidden]>:
> Dear Experts,
>
> Consider:
>
> struct A {
> virtual ~A() = default;
> ....
> };
>
> struct B: A {
> ....
> };
>
>
> class C {
> struct D: B {
> ....
> };
>
> public:
> D* d; // Or unique_ptr<D> etc.
> ....
> };
>
>
> Let's say that C is declared in C.hpp. I could forward-declare D in that
> header:
>
> class C {
> struct D;
> public:
> D* d;
> };
>
>
> Question: has the idea of a "partial forward declaration" ever been
> considered, where
> D is declared as a struct that inherits from B, but with the body omitted?
> E.g.:
>
> class C {
> struct D: B;
> public:
> D* d;
> };
>
>
> The aim is to make it possible for a user of C to use the methods defined
> in A and B,
> while keeping the details of D hidden.
>
> Is this implementable? I could imagine that there could be issues with
> multiple inheritance.
>
> Of course an alternative is:
>
> class C {
> struct D;
> public:
> B* d;
> };
>
> The disadvantage of this is that within the implementation of C, where I
> know that d is
> actually a D*, I would constantly need to cast it.
>
> This idea of partial forward declarations has occurred to me before with
> slightly
> different motivations.
>
> Thoughts anyone?
>
> Phil.
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
yes, it will be hard to add to the language.
пн, 30 дек. 2024 г. в 16:44, Phil Endecott via Std-Proposals <
std-proposals_at_[hidden]>:
> Dear Experts,
>
> Consider:
>
> struct A {
> virtual ~A() = default;
> ....
> };
>
> struct B: A {
> ....
> };
>
>
> class C {
> struct D: B {
> ....
> };
>
> public:
> D* d; // Or unique_ptr<D> etc.
> ....
> };
>
>
> Let's say that C is declared in C.hpp. I could forward-declare D in that
> header:
>
> class C {
> struct D;
> public:
> D* d;
> };
>
>
> Question: has the idea of a "partial forward declaration" ever been
> considered, where
> D is declared as a struct that inherits from B, but with the body omitted?
> E.g.:
>
> class C {
> struct D: B;
> public:
> D* d;
> };
>
>
> The aim is to make it possible for a user of C to use the methods defined
> in A and B,
> while keeping the details of D hidden.
>
> Is this implementable? I could imagine that there could be issues with
> multiple inheritance.
>
> Of course an alternative is:
>
> class C {
> struct D;
> public:
> B* d;
> };
>
> The disadvantage of this is that within the implementation of C, where I
> know that d is
> actually a D*, I would constantly need to cast it.
>
> This idea of partial forward declarations has occurred to me before with
> slightly
> different motivations.
>
> Thoughts anyone?
>
> Phil.
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-12-30 14:10:10