fork download
  1. #include <array>
  2. #include <iostream>
  3. #include <type_traits>
  4. using namespace std;
  5.  
  6. template <typename... T>
  7. constexpr auto make_array(T&&... values) {
  8. using value_type = std::decay_t<std::common_type_t<T...>>;
  9. return std::array<value_type, sizeof...(T)>{std::forward<T>(values)...};
  10. }
  11.  
  12. int main() {
  13. auto a = make_array( 1, 2, 3, 4 );
  14. for ( auto i : a )
  15. std::cout << i << std::endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
1
2
3
4