Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Post Undeleted by masoud
added 170 characters in body
Source Link
masoud
  • 56.8k
  • 18
  • 152
  • 214

Non-copyableWrite a move constructor and Non-copy-constructable. I prefer to deal with smart pointersthen use emplace_back:

struct std:value { ... value(value && obj) :vector<std i_(obj.i_) { } or value(value && obj) = default; ... }; std::unique_ptr<value>>vector<value> v;  for (int i=0; i<10; i++)   v.emplace_back(new value(7)); 

Non-copyable and Non-copy-constructable. I prefer to deal with smart pointers:

 std::vector<std::unique_ptr<value>> v;  for (int i=0; i<10; i++)   v.emplace_back(new value(7)); 

Write a move constructor and then use emplace_back:

struct value { ... value(value && obj) : i_(obj.i_) { } or value(value && obj) = default; ... }; std::vector<value> v; for (int i=0; i<10; i++) v.emplace_back(7); 
Post Deleted by masoud
Source Link
masoud
  • 56.8k
  • 18
  • 152
  • 214

Non-copyable and Non-copy-constructable. I prefer to deal with smart pointers:

 std::vector<std::unique_ptr<value>> v; for (int i=0; i<10; i++) v.emplace_back(new value(7));