I have the following mock code
#include <array>
template<int N>
struct S {
std::array<int, N> m{};
};
template<int N>
auto copy (S<N> const& i) {
return S<i.m.size()>{};
}
int main() {
copy(S<1>{});
}
Is i.m.size()
supposed to be a valid non-type template parameter?
clang9 sais no, gcc9 sais yes: https://godbolt.org/z/PoHjH8
I kind of "get" clang because i
is not constexpr, but since the i.m.size()
is still known at compile time, gcc's approach makes more sense to me.
Who is correct here?