#include <iostream>
#include <vector>
class MyClass
{
private:
std::string _name{};
public:
MyClass(const std::string& name)
:_name(name)
{
std::cout << "create : " << _name << std::endl;
}
MyClass(const MyClass& other) noexcept
{
std::cout << "copy : " << other._name << std::endl;
}
// "noexcept"가 없으면 move가 아닌 copy가 불린다.
MyClass(MyClass&& other) noexcept
{
std::cout << "move : " << other._name << std::endl;
}
};
int main() {
std::vector<MyClass> list;
list.reserve(2);
list.emplace_back("a1");
list.emplace_back("a2");
list.emplace_back("a3");
}