fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3. using namespace std;
  4.  
  5. template<class T> using ptr = T*;
  6.  
  7. template<class T>
  8. void foo(ptr<T> p) { cout << __PRETTY_FUNCTION__ << endl; }
  9.  
  10. template<class T,
  11. enable_if_t< sizeof(T)==1, int > V = 0>
  12. using somechar = T;
  13.  
  14. template<class T> void bar(somechar<T> t) { cout << __PRETTY_FUNCTION__ << endl; }
  15.  
  16. int main() {
  17. int x = 1;
  18. foo(&x);
  19. // foo(x); // will not compile
  20. bar('a');
  21. bar((unsigned char)1);
  22. // bar(1); // no matching function
  23. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
void foo(ptr<T>) [with T = int; ptr<T> = int*]
void bar(somechar<T>) [with T = char; somechar<T> = char]
void bar(somechar<T>) [with T = unsigned char; somechar<T> = unsigned char]