Advertisement
Ilya_konstantinov

harakiri.cpp

Sep 16th, 2024 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | Source Code | 0 0
  1. #include "harakiri.h"
  2.  
  3. OneTimeCallback::OneTimeCallback(const char *s) {
  4.     s_ = std::make_unique<std::string>(std::string(s));
  5. }
  6.  
  7. OneTimeCallback::OneTimeCallback(std::string s) {
  8.     s_ = std::make_unique<std::string>(std::string(s));
  9. }
  10.  
  11. OneTimeCallback::~OneTimeCallback() = default;
  12.  
  13. const std::string OneTimeCallback::operator()() const && {
  14.     std::string s = std::move(*s_);
  15.     return s;
  16. }
  17.  
  18. AwesomeCallback::AwesomeCallback(std::string s) : OneTimeCallback(s) {
  19. }
  20. AwesomeCallback::AwesomeCallback(const char *s) : OneTimeCallback(s) {
  21. }
  22.  
  23. AwesomeCallback::~AwesomeCallback() = default;
  24.  
  25. const std::string AwesomeCallback::operator()() const && {
  26.     std::string s = std::move(*s_);
  27.     s += "awesomeness";
  28.     return s;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement