Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
template<typename ... T>
std::vector<std::string> to_strings(const T& ... t)
{
std::stringstream ss;
return { (ss.str(""), ss << t, ss.str())... };
}
int main()
{
// convert an arbitrary list of things into a vector<string>
for ( const auto &s : to_strings(1, 2.4, 89.3f, "Hello World")) {
std::cout << s << '\n';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.