fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T>
  7. struct A {
  8. A(const T&) {
  9. cout << "A(const A&)" << endl;
  10. }
  11. A(T&&) {
  12. cout << "A(T&&)" << endl;
  13. }
  14. };
  15.  
  16. template <typename T>
  17. A(T&&) -> A<std::remove_reference_t<T>>;
  18.  
  19. int main() {
  20. auto integer{1};
  21. A{1};
  22. A{integer};
  23. return 0;
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:40: error: expected constructor, destructor, or type conversion before ‘;’ token
 A(T&&) -> A<std::remove_reference_t<T>>;
                                        ^
prog.cpp: In function ‘int main()’:
prog.cpp:21:6: error: missing template arguments before ‘{’ token
     A{1};
      ^
prog.cpp:22:6: error: missing template arguments before ‘{’ token
     A{integer};
      ^
stdout
Standard output is empty