Guest User

Untitled

a guest
Dec 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. struct A { };
  2.  
  3. template <int>
  4. struct Parent { };
  5.  
  6. template <int N>
  7. constexpr int operator*(A, Parent<N>*) { return N; }
  8.  
  9. template <class T>
  10. using ptr = T*;
  11.  
  12. template <int>
  13. struct Other { };
  14.  
  15. template <int N>
  16. struct Kid: Parent<N> {
  17. static Other<A{} * ptr<Kid>{}> o;
  18. };
  19.  
  20. int main() {
  21. Kid<2>{};
  22. }
  23.  
  24. prog.cc:7:15: note: candidate template ignored: could not match 'Parent' against 'Kid'
  25. constexpr int operator*(A, Parent<N>*) { return N; }
  26.  
  27. struct A { };
  28.  
  29. template <int>
  30. struct Parent { };
  31.  
  32. template <int N>
  33. constexpr int operator*(A, Parent<N>*) { return N; }
  34.  
  35. template <class T>
  36. using ptr = T*;
  37.  
  38. template <int>
  39. struct Other { };
  40.  
  41. template <int N>
  42. struct Kid: Parent<N> {
  43. static constexpr int s = A{} * ptr<Kid>{};
  44. };
  45.  
  46. int main() {
  47. Other<Kid<2>::s>{};
  48. }
Add Comment
Please, Sign In to add comment