I\'d like to build a std::string
from a std::vector
.
I could use std::stringsteam
, but imagine there is a s
My personal choice would be the range-based for loop, as in Oktalist's answer.
Boost also offers a nice solution:
#include
#include
#include
int main() {
std::vector v{"first", "second"};
std::string joined = boost::algorithm::join(v, ", ");
std::cout << joined << std::endl;
}
This prints:
first, second