fork(2) download
  1. #include <iostream>
  2.  
  3. template <class W, class T>
  4. void foo(W& a, T& t)
  5. {
  6. std::cout << "generic" << std::endl;
  7. }
  8.  
  9. template <template <bool> class W, class T>
  10. void foo(W<true>& a, const T& t)
  11. {
  12. foo(a, const_cast<T&>(t));
  13. }
  14.  
  15. template <class W>
  16. void foo(W& a, int& t)
  17. {
  18. std::cout << "int" << std::endl;
  19. }
  20.  
  21. template <bool> struct what;
  22. template<> struct what<true> { };
  23.  
  24. int main() {
  25. const int ci = 10;
  26. what<true> wt;
  27.  
  28. foo(wt, ci);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
int