-Werror=missing-braces prevents CTAD:
template <std::integral... Args>
void test(Args... args) {
auto x = std::array{static_cast<int>(args)...};
}
int main() {
test(0, 1, 2u, 3u);
}
Once the second level of { ... } is added, it is necessary to specify the full array type:
template <std::integral... Args>
void test(Args... args) {
auto x = std::array<int, sizeof...(Args)>{{static_cast<int>(args)...}};
}
int main() {
test(0, 1, 2u, 3u);
}
Since c++20 seems to support this, I would argue to remove the -Werror flag.
-Werror=missing-bracesprevents CTAD:Once the second level of
{ ... }is added, it is necessary to specify the full array type:Since c++20 seems to support this, I would argue to remove the
-Werrorflag.