Date: Tue, 24 Aug 2021 23:05:21 +0300
On Tue, 24 Aug 2021 at 22:45, Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Tuesday, 24 August 2021 12:42:38 PDT Valery Osheter wrote:
> > I found https://groups.google.com/a/isocpp.org/g/std-proposals/c/9VaHOnP_kPg
> > and it is rejected. I propose simpler solution that does not require to
> > change the syntax nor the standard library. Just allow programmer to
> > declare the public methods of the class.
> >
> > I strongly support the motivation of the authors. The fundamental problem of
> > hiding implementation details still present in modern c++ and requres a
> > cheap and straightforward solution. Forward method declaration can be
> > easely explained and accepted. It does not break the backward compatibility
> > of the language in any form.
>
> I think the motivation is well understood.
>
> But please proceed to a paper, otherwise it'll never happen.
This proposal will need to propose the facility with a different
syntax. extern "C++" definitions of structs and classes
are a thing, especially in a modular world with strong ownership
semantics, and such definitions are not partial.
I may *want* to write such a partial definition that has a particular
linkage, and using 'extern' to mean 'partial'
is far too subtle there.
Other than that, partial forward definitions of classes would be
really nice. Especially if you could then
write template specializations using the partial forward definition
only. Because, if you have a class, and
you need to specialize a template before a member of a class uses that
template on a nested type, C++ doesn't let you do that.
And then things like this are considered, but don't work:
https://codereview.qt-project.org/c/qt/qtbase/+/342275
In other words:
struct X
{
struct Nested {...};
something_that_uses<MyTemplate<Nested>> foo;
};
If you need to specialize MyTemplate for X::Nested before foo, you
can't. The specialization needs to go into the surrounding namespace
scope. But some compilers think the point of instantiation of
MyTemplate<Nested> is well before the point where you can
write the specialization.
If I could do...
struct X partial
{
struct Nested {...};
};
template<> struct MyTemplate<X::Nested> {...};
struct X
{
struct Nested {...};
something_that_uses<MyTemplate<Nested>> foo;
};
...I could ostensibly avoid this problem.
I doubt it's viable to allow the real definition of X to omit the
things defined in the partial definition. A translation
unit that sees the real definition might not see the partial
definition, and then you have a serious ODR problem.
<std-proposals_at_[hidden]> wrote:
>
> On Tuesday, 24 August 2021 12:42:38 PDT Valery Osheter wrote:
> > I found https://groups.google.com/a/isocpp.org/g/std-proposals/c/9VaHOnP_kPg
> > and it is rejected. I propose simpler solution that does not require to
> > change the syntax nor the standard library. Just allow programmer to
> > declare the public methods of the class.
> >
> > I strongly support the motivation of the authors. The fundamental problem of
> > hiding implementation details still present in modern c++ and requres a
> > cheap and straightforward solution. Forward method declaration can be
> > easely explained and accepted. It does not break the backward compatibility
> > of the language in any form.
>
> I think the motivation is well understood.
>
> But please proceed to a paper, otherwise it'll never happen.
This proposal will need to propose the facility with a different
syntax. extern "C++" definitions of structs and classes
are a thing, especially in a modular world with strong ownership
semantics, and such definitions are not partial.
I may *want* to write such a partial definition that has a particular
linkage, and using 'extern' to mean 'partial'
is far too subtle there.
Other than that, partial forward definitions of classes would be
really nice. Especially if you could then
write template specializations using the partial forward definition
only. Because, if you have a class, and
you need to specialize a template before a member of a class uses that
template on a nested type, C++ doesn't let you do that.
And then things like this are considered, but don't work:
https://codereview.qt-project.org/c/qt/qtbase/+/342275
In other words:
struct X
{
struct Nested {...};
something_that_uses<MyTemplate<Nested>> foo;
};
If you need to specialize MyTemplate for X::Nested before foo, you
can't. The specialization needs to go into the surrounding namespace
scope. But some compilers think the point of instantiation of
MyTemplate<Nested> is well before the point where you can
write the specialization.
If I could do...
struct X partial
{
struct Nested {...};
};
template<> struct MyTemplate<X::Nested> {...};
struct X
{
struct Nested {...};
something_that_uses<MyTemplate<Nested>> foo;
};
...I could ostensibly avoid this problem.
I doubt it's viable to allow the real definition of X to omit the
things defined in the partial definition. A translation
unit that sees the real definition might not see the partial
definition, and then you have a serious ODR problem.
Received on 2021-08-24 15:05:39