N4687:
[Annex D (normative) Compatibility features]
D.1 Redeclaration of static constexpr data members
1 For compatibility with prior C++ International Standards, a constexpr static data member may be redundantly redeclared outside the class with no initializer. This usage is deprecated. [ Example:
struct A {
static constexpr int n = 5; // definition (declaration in C++ 2014)
};
constexpr int A::n; // redundant declaration (definition in C++ 2014)
— end example ]
I don't have a good command of English, so I am confronted with several questions when learning standard(I'm just coming from odr-use)
This usage is deprecated
whichusage
does here mean?- definition (declaration in C++ 2014)
- redundant declaration (definition in C++ 2014)
the two comments confuse me. Here is two possibility:
i.
Until C++ 2014(c++14/1y),
static constexpr int n = 5;
is adefinition
.constexpr int A::n;
is aredundant declaration
.Since C++17(or after c++14),
static constexpr int n = 5;
is adeclaration
.constexpr int A::n;
is adefinition
ii.
Since C++17(or after c++14),
static constexpr int n = 5;
is adefinition
.constexpr int A::n;
is aredundant declaration
.Before c++17(which include c++ 2014),
static constexpr int n = 5
is adeclaration
.constexpr int A::n;
is adefinition
.
i
and ii
, which is true?