Skip to content

Instantly share code, notes, and snippets.

@alekswn
Last active July 23, 2017 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alekswn/29a9e9f567ca62ae3ce2510b40851441 to your computer and use it in GitHub Desktop.
Save alekswn/29a9e9f567ca62ae3ce2510b40851441 to your computer and use it in GitHub Desktop.
#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