mercredi 21 septembre 2022

Converting init-statements to earlier c++ compiler

I found a function that I would like to steal and add to my project. The only problem is that I keep getting the error that it is only c++17 compatible which does not work for my current project.

Here is the code:

  std::string JoinVectorByStringA(const std::vector<std::string>& v, const std::string& delimiter)
{
    std::string out;
    if (auto i = v.begin(), e = v.end(); i != e)
    {
        out += *i++;
        for (; i != e; ++i)
        {
            out.append(delimiter).append(*i);
        }
    }
    return out;
}

I have tried various approaches but they have added more errors. I am using MSVC 2019 (v142). Does anyone know how to make this compatible?

Thank you.

Aucun commentaire:

Enregistrer un commentaire