Date: Fri, 05 Mar 2021 00:07:14 +0300
In the C++ 20 Standard (Draft 4860) there is written (11.4 Class members)
5 A member shall not be declared twice in the member-specification, except that
(5.1) — a nested class or member class template can be declared and then later defined, and
It can be understood as either the enclosed class has one declaration of the nested class or it contains at first a declaration without the definition of the nested class and then a declaration that is at the same time its definition.
However this declaration
struct A
{
struct B;
struct B {};
struct B;
};
compiles successfully by most of compilers.
Is that declaration of the structure A with the nested structure B valid or should the quote be rewritten such a way that it would be clear that such a declaration is ill-formed?
With best regards
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
5 A member shall not be declared twice in the member-specification, except that
(5.1) — a nested class or member class template can be declared and then later defined, and
It can be understood as either the enclosed class has one declaration of the nested class or it contains at first a declaration without the definition of the nested class and then a declaration that is at the same time its definition.
However this declaration
struct A
{
struct B;
struct B {};
struct B;
};
compiles successfully by most of compilers.
Is that declaration of the structure A with the nested structure B valid or should the quote be rewritten such a way that it would be clear that such a declaration is ill-formed?
With best regards
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
Received on 2021-03-04 15:07:20