fork download
  1. #include <type_traits>
  2.  
  3. struct Test{
  4. template<class T>
  5. Test(T &t) : Test<T, typename std::is_const<T>::type>(t){}
  6.  
  7. template<class T, class D>
  8. Test(T &t){ "t ist irgendwas!"; }
  9.  
  10. template<class T, std::true_type>
  11. Test(T &t){ "t ist const!"; }
  12.  
  13. template<class T, std::false_type>
  14. Test(T &t){ "t ist nicht const!"; }
  15. };
  16.  
  17. int main() {
  18. // your code goes here
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:10:25: error: ‘struct std::integral_constant<bool, true>’ is not a valid type for a template non-type parameter
  template<class T, std::true_type>
                         ^
prog.cpp:11:2: error: ‘template<class T, <declaration error> > Test::Test(T&)’ cannot be overloaded
  Test(T &t){ "t ist const!"; }
  ^
prog.cpp:8:2: error: with ‘template<class T, class D> Test::Test(T&)’
  Test(T &t){ "t ist irgendwas!"; }
  ^
prog.cpp:13:25: error: ‘struct std::integral_constant<bool, false>’ is not a valid type for a template non-type parameter
  template<class T, std::false_type>
                         ^
prog.cpp:14:2: error: ‘template<class T, <declaration error> > Test::Test(T&)’ cannot be overloaded
  Test(T &t){ "t ist nicht const!"; }
  ^
prog.cpp:8:2: error: with ‘template<class T, class D> Test::Test(T&)’
  Test(T &t){ "t ist irgendwas!"; }
  ^
prog.cpp: In constructor ‘Test::Test(T&)’:
prog.cpp:5:15: error: ‘struct Test Test::Test’ is not a non-static data member of ‘Test’
  Test(T &t) : Test<T, typename std::is_const<T>::type>(t){}
               ^
prog.cpp:5:19: error: expected ‘(’ before ‘<’ token
  Test(T &t) : Test<T, typename std::is_const<T>::type>(t){}
                   ^
prog.cpp:5:19: error: expected ‘{’ before ‘<’ token
stdout
Standard output is empty