c++ 17, is it possible to parameterize uniform initialization of vector?

  c++, c++17, parameters, uniform-initialization

I have a vector of 2N lines where the second half (N lines) is basically the same as the first half but with a single character changed, e.g.:

std::vector<std::string> tests{
      // First half of lines with '=' as separator between key and value
      "key=value",
      ...
      // Second half of lines with ' ' as separator between key and value
      "key value",
      ...
};

Is there a way to parameterize the separator (i.e., = or ) to avoid repeating the lines during the initialization, using the uniform initialization construct? I wonder if there’s a better way than creating it with a for loop.

Thanks

Source: Windows Questions C++

LEAVE A COMMENT