Guest User

Untitled

a guest
Sep 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. struct Base {
  2. virtual void junk() = 0;
  3. };
  4.  
  5. template <class T>
  6. struct Derived : Base {
  7.  
  8. void junk() override {
  9. T::junkImpl();
  10. }
  11.  
  12. void otherMethod() {
  13. }
  14. };
  15.  
  16.  
  17. template <class T>
  18. struct NotDerived {
  19.  
  20. void junk() {
  21. T::junkImpl();
  22. }
  23.  
  24. void otherMethod() {
  25. }
  26. };
  27.  
  28.  
  29. struct TypeWithJunk {
  30. void junkImpl() {
  31. }
  32. };
  33.  
  34. struct TypeWithoutJunk {};
  35.  
  36.  
  37. void reproduce(NotDerived<TypeWithoutJunk>* ndt, Derived<TypeWithoutJunk>* dt) {
  38.  
  39. // works - junk is not used, not instantiated
  40. ndt->otherMethod();
  41.  
  42. // fails on MSVC - junk is instantiated even if not used
  43. dt->otherMethod();
  44. }
Add Comment
Please, Sign In to add comment