Last active
May 25, 2016 04:08
-
-
Save lefticus/2a4a317885dc2f9b2ff99f62d2bb6729 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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