Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. std::array arr{ 1, 2, 3, 4, 5 }; // with C++17 template argument deduction
  2. std::array<int, 5> arr{ 1, 2, 3, 4, 5 }; // just a normal C++11 std::array
  3.  
  4. std::array arr{ 1, 2, 3.f, 4, 5 };
  5.  
  6. main.cpp:7:26: error: class template argument deduction failed:
  7. std::array arr{2,4.,5}; // will not compile
  8.  
  9. std::array<float> arr{ 1, 2, 3.f, 4, 5 }; // will not compile as well
  10.  
  11. main.cpp:7:21: error: wrong number of template arguments (1, should be 2)
  12. std::array<float> arr{2,4.,5};
  13. ^
  14.  
  15. std::tuple t(1, 2, 3); // OK: deduction
  16. std::tuple<int,int,int> t(1, 2, 3); // OK: all arguments are provided
  17. std::tuple<int> t(1, 2, 3); // Error: partial deduction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement