This code rejected by clang because t.n
is not compile-time constant.
template<int N>
struct s{
constexpr static int n = N;
};
template<typename T>
void test(T& t){
static_assert(t.n == 1);
}
int main(){
s<1> str;
test(str);
}
But g++ let this go.
Which is the standard-compliant behavior?
One more curious fact is, if I change test
's argument from T& t
to T t
, this will build on both.
What is changed about const-ness?
(I afraid the title may not describe this question correctly, or in detail. Feel free to give me more suitable title)