Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <set>
  2.  
  3. using namespace std;
  4.  
  5. struct A {};
  6.  
  7. struct X
  8. {
  9.     template <typename T> void set(T x) {}
  10. };
  11.  
  12. struct Y : X {};
  13.  
  14. void f()
  15. {
  16.     Y y;
  17.     A a;
  18.     y.set<A>(a);
  19. }
  20.  
  21. /*
  22.  
  23. $ clang++ -Wall -std=c++98 -c test.cpp
  24. test.cpp:19:4: warning: lookup of 'set' in member access expression is ambiguous; using member of 'Y' [-Wambiguous-member-template]
  25.         y.set<A>(a);
  26.           ^
  27. test.cpp:10:29: note: lookup in the object type 'Y' refers here
  28.         template <typename T> void set(T x) {}
  29.                                    ^
  30. In file included from test.cpp:2:
  31. In file included from /usr/include/c++/4.4/set:60:
  32. /usr/include/c++/4.4/bits/stl_set.h:87:11: note: lookup from the current scope refers here
  33.     class set
  34.           ^
  35. 1 warning generated.
  36.  
  37.  
  38. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement