In cppref it gives the syntax of constant initialization:
static T & ref = constexpr;
static T object = constexpr;
But wait,how could a lvalue reference T & without const be bound to a consexptr,which is constant and unmodifiable ?
I try to provide some example but failed:
static int& ref = 6; //error, need a `const`
constexpr int a = 6; static int& ref = a; //error, need a `const`
Aucun commentaire:
Enregistrer un commentaire