Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. int LegacyFunction(const char *s) {
  2. // do something with s, like print it to standard output
  3. // this function does NOT retain any pointer to s after it returns.
  4. return strlen(s);
  5. }
  6.  
  7. std::string ModernFunction() {
  8. // do something that returns a string
  9. return "Hello";
  10. }
  11.  
  12. LegacyFunction(ModernFunction().c_str());
  13.  
  14. LegacyFunction(ModernFunction().c_str());
  15.  
  16. struct S {
  17. S(int i): I(i) { }
  18. int& v() { return I; }
  19. private:
  20. int I;
  21. };
  22. S s1(1); // full-expression is call of S::S(int)
  23. S s2 = 2; // full-expression is call of S::S(int)
  24. void f() {
  25. if (S(3).v()) // full-expression includes lvalue-to-rvalue and
  26. // int to bool conversions, performed before
  27. // temporary is deleted at end of full-expression
  28. { }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement