fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T> struct TypeReader { static std::string read() { return typeid(T).name(); } };
  5. template<typename T> std::string read_type(T&) { return TypeReader<T>::read(); }
  6. template<typename T> std::string read_type(const T&) { return TypeReader<const T>::read(); }
  7. template<typename T> std::string read_type(volatile T&) { return TypeReader<volatile T>::read(); }
  8. template<typename T> std::string read_type(const volatile T&) { return TypeReader<const volatile T>::read(); }
  9.  
  10.  
  11. int main() {
  12. std::cout << read_type<int(*(&)[42])()>() << std::endl;
  13. return 0;
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:42: error: no matching function for call to ‘read_type<int (* (&)[42])()>()’
  std::cout << read_type<int(*(&)[42])()>() << std::endl;
                                          ^
prog.cpp:5:34: note: candidate: ‘template<class T> std::__cxx11::string read_type(T&)’
 template<typename T> std::string read_type(T&) { return TypeReader<T>::read(); }
                                  ^~~~~~~~~
prog.cpp:5:34: note:   template argument deduction/substitution failed:
prog.cpp:12:42: note:   candidate expects 1 argument, 0 provided
  std::cout << read_type<int(*(&)[42])()>() << std::endl;
                                          ^
prog.cpp:6:34: note: candidate: ‘template<class T> std::__cxx11::string read_type(const T&)’
 template<typename T> std::string read_type(const T&) { return TypeReader<const T>::read(); }
                                  ^~~~~~~~~
prog.cpp:6:34: note:   template argument deduction/substitution failed:
prog.cpp:12:42: note:   candidate expects 1 argument, 0 provided
  std::cout << read_type<int(*(&)[42])()>() << std::endl;
                                          ^
prog.cpp:7:34: note: candidate: ‘template<class T> std::__cxx11::string read_type(volatile T&)’
 template<typename T> std::string read_type(volatile T&) { return TypeReader<volatile T>::read(); }
                                  ^~~~~~~~~
prog.cpp:7:34: note:   template argument deduction/substitution failed:
prog.cpp:12:42: note:   candidate expects 1 argument, 0 provided
  std::cout << read_type<int(*(&)[42])()>() << std::endl;
                                          ^
prog.cpp:8:34: note: candidate: ‘template<class T> std::__cxx11::string read_type(const volatile T&)’
 template<typename T> std::string read_type(const volatile T&) { return TypeReader<const volatile T>::read(); }
                                  ^~~~~~~~~
prog.cpp:8:34: note:   template argument deduction/substitution failed:
prog.cpp:12:42: note:   candidate expects 1 argument, 0 provided
  std::cout << read_type<int(*(&)[42])()>() << std::endl;
                                          ^
stdout
Standard output is empty