fork 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 <class W>
  10. void foo(W& a, int& t)
  11. {
  12. std::cout << "int" << std::endl;
  13. }
  14.  
  15. template <template <bool> class W, class T>
  16. void foo(W<true>& a, const T& t)
  17. {
  18. ::foo(a, const_cast<T&>(t));
  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