fork download
  1. #include <map>
  2. #include <tuple>
  3. #include <iostream>
  4.  
  5. class NixeCopy {
  6. public:
  7. NixeCopy(NixeCopy const&) = delete;
  8. NixeCopy(NixeCopy&&) = delete;
  9. NixeCopy& operator =(NixeCopy const&) = delete;
  10. NixeCopy& operator =(NixeCopy&&) = delete;
  11.  
  12. NixeCopy(int a, int b) : a(a), b(b) {}
  13.  
  14. int dings() const { return a + b; }
  15.  
  16. private:
  17. int a;
  18. int b;
  19. };
  20.  
  21. int main() {
  22. std::map<int, NixeCopy> m;
  23. m.emplace(
  24. std::piecewise_construct,
  25. std::make_tuple(42),
  26. std::make_tuple(222, 444));
  27.  
  28. auto it = m.find(42);
  29. if (it != m.end()) {
  30. std::cout << "found: " << it->second.dings() << "\n";
  31. } else {
  32. std::cout << "not found :(\n";
  33. }
  34. }
  35.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
found: 666