Pass the string as argument to the constructor and read from it the same way as you would from std::cin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <sstream>
int main ()
{
std::istringstream iss("hello 123");
std::string word;
iss >> word;
int num;
iss >> num;
std::cout << num << " " << word << "\n"; // prints "123 hello"
}
However these (and from_chars() ) just convert one value. They're not really the opposite of std::format() which can deal with multiple values. Until std:parse() comes, the nearest is sscanf().