I have some doubts about constexpr and auto when applied to references.
From what I've read, constexpr imposes top-level const. In that case, what's the effect of doing:
Code:
constexpr int &ref = i; // i is a global non-const variable
This doesn't make sense to me as we can't have a const reference (only a reference to const).
Likewise, with auto:
Code:
const int i = 10;
// ok; auto retains the low-level const and ref is a reference to a const int
auto &ref = i;
auto &ref2 = 10; // error; the low-level const cannot be inferred here
const auto &ref3 = 10; // ok, adding top-level const fixes it
Why `const auto` here has a different meaning than when declaring any other type?
Is there an explanation for this cases or this is just the way it is and those use of auto and constexpr with references are an exception?
Thanks in advance.