fork(2) download
  1. #include <functional>
  2. #include <memory>
  3.  
  4. template<typename T>
  5. struct identity
  6. {
  7. using type = T;
  8. };
  9.  
  10. template<int a> struct bar;
  11.  
  12. template<int a, int b> struct foo {
  13. operator bar<a> const (); // operator-based conversion
  14. };
  15.  
  16. template<int a> struct bar : public foo<a, a> {
  17. bar() { }
  18. template<int b> bar(const foo<a, b>&) { } // constructor-based conversion
  19. };
  20.  
  21. template<int a, int b> foo<a, b>::operator bar<a> const () { return bar<a>(); }
  22.  
  23. template<int a> void f(bar<a> x, typename identity<bar<a>>::type y) { }
  24.  
  25. int main() {
  26. bar<1> x;
  27. foo<1, 2> y;
  28. f(x, y);
  29. }
  30.  
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty