In this answer I wrote the C++17 code:
cout << accumulate(cbegin(numbers), cend(numbers), decay_t<decltype(numbers[0])>{});
This received some negative commentary about the nature of C++'s type association, which I'm sad to say that I agree with :(
decay_t<decltype(numbers[0])>{}
is a very complex way to get a:
Zero-initialized type of an element of
numbers
Is it possible to maintain the association with the type of numbers
' elements, but not type like 30 characters to get it?
Aucun commentaire:
Enregistrer un commentaire