fork download
  1. #include <memory>
  2.  
  3. class C;
  4. std::unique_ptr<C> pC;
  5.  
  6. C& f() {
  7. if (!pC) throw 0; // OK, even though C is incomplete
  8. return *pC; // OK, even though C is incomplete
  9. }
  10.  
  11. template <class T>
  12. class X
  13. {
  14. T t;
  15. };
  16.  
  17. std::unique_ptr<X<C>> pX;
  18.  
  19. typename std::add_lvalue_reference<X<C>>::type DoSomeStuff() // exact copy of operator*
  20. {
  21. return (*pX.get());
  22. }
  23.  
  24. void g() {
  25. if ((bool)pX) return;
  26. }
  27.  
  28. class C {};
  29.  
  30. int main()
  31. {
  32. auto z = DoSomeStuff();
  33. }
  34.  
  35.  
  36.  
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty