fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <list>
  5. #include <type_traits>
  6.  
  7.  
  8. template<typename C>
  9. void f(C &cont )
  10. {
  11. static_assert( !std::is_same<typename C::value_type, char>::value, "error" );
  12. std::cout << *cont.begin() << std::endl;
  13. }
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17. std::vector<int> v{1,2,3};
  18. std::list<char> l{'a','b','c'};
  19. std::set<int> s{4,5,6};
  20. f(v);
  21. f(l);
  22. f(s);
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘void f(C&) [with C = std::__cxx11::list<char>]’:
prog.cpp:21:8:   required from here
prog.cpp:11:5: error: static assertion failed: error
     static_assert( !std::is_same<typename C::value_type, char>::value, "error" );
     ^~~~~~~~~~~~~
stdout
Standard output is empty