#include <string>
#include <algorithm>
#include <map>
#include <iostream>
int main()
{
std::vector<std::string> d {"hello world"};
std::map<std::string, std::string> m;
std::for_each(d.cbegin(), d.cend(), [&m](const std::string& v){ auto pos = v.cbegin() + v.find(" ");
m.emplace(std::string(v.cbegin(), pos), std::string(std::next(pos), v.cend()));});
std::cout << m.cbegin()->first << "\n" << m.cbegin()->second << "\n";
}
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
std::string str[3] = { "foo bar", "baz quux", "x y" };
std::map<std::string, std::string> d;
for (auto const & s : str)
{
auto it = s.find(' ');
if (it != std::string::npos)
d[s.substr(0, it)] = s.substr(it + 1);
}
for (auto const & kv : d)
std::cout << kv.first << " = " << kv.second << std::endl;