I am new to C++ and I am curious about why the reference of a variable with external linkage is treated as constant expression in the following example:
<code>template<decltype(auto) N>
class C {
};
int i;
// not allowed
//C<i> x;
C<(i)> x;
</code>
<code>template<decltype(auto) N>
class C {
};
int i;
// not allowed
//C<i> x;
C<(i)> x;
</code>
template<decltype(auto) N>
class C {
};
int i;
// not allowed
//C<i> x;
C<(i)> x;
In the above example, the type of the non-type template parameter N
is int &
due to the non-type template argument (i)
.