Boost join can be used to concatenate a container of strings optionally separated by a separator string as shown in this example: A good example for boost::algorithm::join>
Sure, you can combine boost::algorithm::join and boost::adaptors::transformed to convert the doubles to strings and then join them together.
#include
#include
#include
#include
#include
int main()
{
using boost::adaptors::transformed;
using boost::algorithm::join;
std::vector v{1.1, 2.2, 3.3, 4.4};
std::cout
<< join( v |
transformed( static_cast(std::to_string) ),
", " );
}
Output:
1.100000, 2.200000, 3.300000, 4.400000
You can also use a lambda to avoid the ugly cast
join(v | transformed([](double d) { return std::to_string(d); }), ", ")