#include <list>
#include <iostream>
#include <sstream>
#include <iterator>
#include <string>
std::list<std::list<std::string>> split(const std::list<std::string>& bulk)
{
std::list<std::list<std::string>> splitdata;
for(auto& str: bulk)
{
std::istringstream buf(str);
splitdata.emplace_back(
std::istream_iterator<std::string>(buf),
std::istream_iterator<std::string>());
}
return splitdata;
}
int main()
{
std::list<std::string> in = {"this is an example", "this is another"};
std::list<std::list<std::string>> out = split(in);
for(auto& row: out) {
for(auto& str: row)
std::cout << "'" << str << "' ";
std::cout << '\n';
}
}
I2luY2x1ZGUgPGxpc3Q+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxpdGVyYXRvcj4KI2luY2x1ZGUgPHN0cmluZz4KCnN0ZDo6bGlzdDxzdGQ6Omxpc3Q8c3RkOjpzdHJpbmc+PiBzcGxpdChjb25zdCBzdGQ6Omxpc3Q8c3RkOjpzdHJpbmc+JiBidWxrKQp7CiAgICBzdGQ6Omxpc3Q8c3RkOjpsaXN0PHN0ZDo6c3RyaW5nPj4gc3BsaXRkYXRhOwogICAgZm9yKGF1dG8mIHN0cjogYnVsaykKICAgIHsKICAgICAgICBzdGQ6OmlzdHJpbmdzdHJlYW0gYnVmKHN0cik7CiAgICAgICAgc3BsaXRkYXRhLmVtcGxhY2VfYmFjaygKICAgICAgICAgICAgIHN0ZDo6aXN0cmVhbV9pdGVyYXRvcjxzdGQ6OnN0cmluZz4oYnVmKSwKICAgICAgICAgICAgIHN0ZDo6aXN0cmVhbV9pdGVyYXRvcjxzdGQ6OnN0cmluZz4oKSk7CiAgICB9CiAgICByZXR1cm4gc3BsaXRkYXRhOwp9CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6bGlzdDxzdGQ6OnN0cmluZz4gaW4gPSB7InRoaXMgaXMgYW4gZXhhbXBsZSIsICJ0aGlzIGlzIGFub3RoZXIifTsKICAgIHN0ZDo6bGlzdDxzdGQ6Omxpc3Q8c3RkOjpzdHJpbmc+PiBvdXQgPSBzcGxpdChpbik7CiAgICBmb3IoYXV0byYgcm93OiBvdXQpIHsKICAgICAgICBmb3IoYXV0byYgc3RyOiByb3cpCiAgICAgICAgICAgc3RkOjpjb3V0IDw8ICInIiA8PCBzdHIgPDwgIicgIjsKICAgICAgIHN0ZDo6Y291dCA8PCAnXG4nOwogICAgfQp9Cg==