Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <tuple>
  2. #include <string>
  3. #include <string.h>
  4. template<typename T>
  5. class foo
  6. {
  7. public:
  8. foo(T storage) : storage_(std::move(storage)) {}
  9. private:
  10. T storage_;
  11. };
  12.  
  13. int main()
  14. {
  15. char* s2 = strdup("123");
  16.  
  17. foo f { std::make_tuple(12,123,"1234") };
  18.  
  19. foo f2 { std::make_tuple("321", s2) };
  20.  
  21. free(s2);
  22. // still want to keep s2 stored in f2
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement