My first try of using decltype
vector<int> vals;
const decltype(&vals[0]) ptr;
for (const auto& val : vals)
ptr = &val;
doesn't compile, complaining about assigning to read-only variable ptr
. What I'm trying to achieve is ptr
to be of type const int*
. How can I make it work? Thanks.
Aucun commentaire:
Enregistrer un commentaire