vendredi 22 mars 2019

C++11 type alias of std::array with operators

I have a c++11 type alias:

using coord = std::array<double, 3>;

Can I define the operator + for coord? How? I'd want to be able to do:

coord a, b, c;
a = {1.1, 2.0, 0};
b = {0, -1, 3.5};
c = a + b; // c = {1.1, 1.0, 3.5}

Aucun commentaire:

Enregistrer un commentaire