lundi 27 décembre 2021

Parsing stringstream into std::array [duplicate]

I am reading data from a file of the type (0 0 0) which I would like to put in a std::array.

When I compile the code I get an error saying that the >> is not overloaded.

I have:

#include <array>
#include <sstream>
#include <string>

int main(int argCount, char *args[])
{

    std::string tst ("(0 0 0)");

    std::istringstream is (tst);

    std::array<double, 3> myVec; 

    is >> myVec;

    return 0;
}

How can I overload the >>operator to collect the data?

Would really appreciate the help.

Aucun commentaire:

Enregistrer un commentaire