次はC++ 14でgccと打ち鳴らすの両方でコンパイルに失敗しますが、C++ 1Zに成功:constexpr静的データメンバーの再定義は今では許可されていますか? (インラインconstではなく)?
struct Cls {
static constexpr int N = 0;
};
constexpr int Cls::N;
constexpr int Cls::N;
C++ 14のエラーが予測可能である:redefinition of ‘constexpr const int Cls::N’
に何が変わりましたこれを法的にする?私が見つかりました:
n4659 10.1.5 [dcl.constexpr]
関数または静的データメンバは、constexprので宣言 指定子は暗黙インライン関数または変数
ある
だから私はそれがインライン変数と関係があるかもしれないと思ったが、両方のコンパイラの下で、次のことはC++ 1zで失敗する
struct Cls {
static inline const int N = 0;
};
inline const int Cls::N; // note, only one definition here