All I\'ve found is boost::algorithm::string::join
. However, it seems like overkill to use Boost only for join. So maybe there are some time-tested recipes?
Here is another version that I find more handy to use:
std::string join(std::initializer_list initList, const std::string& separator = "\\")
{
std::string s;
for(const auto& i : initList)
{
if(s.empty())
{
s = i;
}
else
{
s += separator + i;
}
}
return s;
}
You can then call it this way:
join({"C:", "Program Files", "..."});