Example below.
constexpr int x =1; -- type const int
constexpr int &y=x; -- error because type for reference y is int &
According to the link discussion C++: constexpr implying implicit const to variables does not apply to reference, constexpr keyword always refers to the object in the declaration (not the type).
So why the type for x is const int while y is int &?
Aucun commentaire:
Enregistrer un commentaire