Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. template<int a> struct bar;
  2.  
  3. template<int a, int b> struct foo {
  4. operator bar<a> const (); // operator-based conversion
  5. };
  6.  
  7. template<int a> struct bar : public foo<a, a> {
  8. bar() { }
  9. template<int b> bar(const foo<a, b>&) { } // constructor-based conversion
  10. };
  11.  
  12. template<int a, int b> foo<a, b>::operator bar<a> const () { return bar<a>(); }
  13.  
  14. template<int a> void f(bar<a> x, bar<a> y) { }
  15.  
  16. int main() {
  17. bar<1> x;
  18. foo<1, 2> y;
  19. f(x, y);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement