jeudi 21 juillet 2016

C++11 variadic function without template type?

Is it possible to have a function with a variadic number of non-template-type parameters?

For example, a function that takes an arbitrary number of strings

std::string concat_all() { return ""; }

std::string concat_all(std::string const& s,
                       std::string const&... t) // won't compile
{
    return s + concat_all(t...);
}

Aucun commentaire:

Enregistrer un commentaire