fork download
  1. #include <array>
  2. #include <experimental/array>
  3. #include <iostream>
  4. #include <typeinfo>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. // std::array arr = { 1, 2, 3.4 }; // error
  10.  
  11. // creates array of doubles
  12. auto arr = std::experimental::make_array(1, 2, 3.4);
  13.  
  14. bool is_array_of_3_doubles = std::is_same<decltype(arr), std::array<double, 3>>::value;
  15. std::cout << "Returns an array of three doubles? ";
  16. std::cout << std::boolalpha << is_array_of_3_doubles << '\n';
  17.  
  18. // creates array of ints
  19. auto ra = std::experimental::make_array<int> (1, 2, 3.4);
  20.  
  21. bool is_array_of_3_ints = std::is_same<decltype(ra), std::array<int, 3>>::value;
  22. std::cout << "Returns an array of three ints? ";
  23. std::cout << std::boolalpha << is_array_of_3_ints << '\n';
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 4172KB
stdin
Standard input is empty
stdout
Returns an array of three doubles? true
Returns an array of three ints? true