Why a constexpr static
data member needs to be defined outside of the class on C++11
, C++14
but it doesn't need that requirement on c++ 17
, 20
and above?
struct Array{
int static constexpr sz_ = 5;
int ar_[sz_]{};
};
//int constexpr Array::sz_; // needed on `C++11`, `C++14` but not needed for C++17, C++20
void foo(int const& x){
}
int main(){
foo(Array::sz_);
}
- So is this a change in the standard? or should I always define that member outside of the class?
Aucun commentaire:
Enregistrer un commentaire