lundi 27 mai 2019

Why does std::array not have an operator()?

With C arrays, it's been the case that simply naming an array has the same effect as writing &foo[0] for something approaching 50 years.

When converting from C style arrays to std::array<> in a project I'm working on, the vast majority of "error"s that appeared were due to the above property of C arrays.

In all cases, the solution was trivial, just append .data(). However it occurred to me that a carefully crafted operator() ought to directly solve this issue.

Is there any good reason this operator doesn't exist?

Aucun commentaire:

Enregistrer un commentaire