T
Size: a a a
T
Е
V
V
P
V
T
#include <iostream>
#include <memory>
struct X {
int id;
X(int id) : id(id) {
std::cout << id << " created\n";
}
X(const X& other) : id(other.id) {
std::cout << id << " copied\n";
}
X(X&& other) : id(other.id) {
std::cout << id << " moved\n";
}
X& operator=(X) = delete; // no assignment
~X() = default;
};
template <typename T, typename Arg>
std::unique_ptr<T> my_make_unique(Arg&& arg) {
return std::unique_ptr<T>( new T(std::forward<Arg>(arg)) );
}
int main() {
auto ptr = my_make_unique<X>(X(1));
}
A
V
V
DP
Е
DP
V
V
V
V
DP