const string buf = vector_of_strings | views::join | ranges::to<string>() works, but not with: views::join_with(vector_of_strings, string_view(", "))
04:45 13 Jun 2026

Currently, I'm concatenating the values of a vector with this statement:
const string buf = configAbsoluteFilesNames | views::join | ranges::to();
and it works: in the program below, I receive:
/i_do_not_exist/a.file/i_do_not_exist/b.file

But I'd like to use inside a:

views::join_with(configAbsoluteFilesNames, string_view(", "))

instead. So that I could have problematic values separated by a , :
/i_do_not_exist/a.file, /i_do_not_exist/b.file

But I do not understand how to make that change in the dedicated statement.

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

int main() {
   vector configAbsoluteFilesNames = {"/i_do_not_exist/a.file", 
      "/i_do_not_exist/b.file"};

   auto join = views::join_with(configAbsoluteFilesNames, string_view(", ")); // unused yet. How to integrate it in the statement below?
   const string buf = configAbsoluteFilesNames | views::join | ranges::to();

   string message = format("Failed to read configuration file: {}", buf);
   println("{}", message);

   return 0;
}

I've tried:

const string buf = configAbsoluteFilesNames | 
   views::join_with(configAbsoluteFilesNames, string_view(", ")) | 
   ranges::to();

that looked to me the nearest in the spirit of what should be done, but I have a compilation error:

No viable operator| matches arguments of type vector and ranges::join_with_view>, string_view>.

How should I put my change in practice?

c++ stdvector std-ranges