dmd 2.063 beta 5
TommiT
tommitissari at hotmail.com
Thu May 23 16:15:29 PDT 2013
On Thursday, 23 May 2013 at 13:01:25 UTC, Don wrote:
> I don't think it's legal in C++:
>
> struct S
> {
> const int x = 5;
> };
>
> w.cpp:4:17: error: ISO C++ forbids initialization of member ‘x’
> [-fpermissive]
That is legal C++11 code. The non-static data member initializer
(=5) simply adds an implicit entry (if not present) for that
particular data member to each constructor initialization list.
Thus, the struct S above is the same as:
struct S
{
const int x;
S() : x (5) { }
};
The fact that the field is const doesn't play any significant
role here.
More information about the Digitalmars-d-announce
mailing list