Last active
July 23, 2017 07:52
-
-
Save alekswn/29a9e9f567ca62ae3ce2510b40851441 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 <iostream> | |
#include <string> | |
#include <array> | |
#include <type_traits> | |
using std::cout; | |
using std::endl; | |
using std::array; | |
template<typename... Ts> | |
constexpr auto make_array(Ts&&... ts) | |
-> std::array<std::common_type_t<Ts...>,sizeof...(ts)> | |
{ | |
return {{ std::forward<Ts>(ts)... }}; | |
} | |
template<typename... Targs> | |
void func(const Targs&... args) { | |
for (const auto& arg : make_array(args...)) | |
cout << arg << " "; | |
cout << endl; | |
} | |
int main() { | |
func("one", "two", "three"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment