#include <iostream>
#include <vector>
class X
{
int i_;
int* p_;
public:
struct special
{
unsigned c;
unsigned dt;
unsigned cc;
unsigned ca;
unsigned mc;
unsigned ma;
};
static special sp;
X(int i, int* p)
: i_(i)
, p_(p)
{
// std::cout << "X(int i, int* p)\n";
sp.c++;
}
~X()
{
// std::cout << "~X()\n";
sp.dt++;
}
X(const X& x)
: i_(x.i_)
, p_(x.p_)
{
// std::cout << "X(const X& x)\n";
sp.cc++;
}
X& operator=(const X& x)
{
i_ = x.i_;
p_ = x.p_;
// std::cout << "X& operator=(const X& x)\n";
sp.ca++;
return *this;
}
X(X&& x) noexcept
: i_(x.i_)
, p_(x.p_)
{
// std::cout << "X(X&& x)\n";
sp.mc++;
}
X& operator=(X&& x) noexcept
{
i_ = x.i_;
p_ = x.p_;
// std::cout << "X& operator=(X&& x)\n";
sp.ma++;
return *this;
}
};
std::ostream&
operator<<(std::ostream& os, X::special const& sp)
{
os << sp.c << '\n';
os << sp.dt << '\n';
os << sp.cc << '\n';
os << sp.ca << '\n';
os << sp.mc << '\n';
os << sp.ma << '\n';
return os;
}
X::special X::sp{};
int
main()
{
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--insert lvalue no reallocation--\n";
X::sp = {};
v.insert(v.begin(), x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace lvalue no reallocation--\n";
X::sp = {};
v.emplace(v.begin(), x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--insert xvalue no reallocation--\n";
X::sp = {};
v.insert(v.begin(), std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace xvalue no reallocation--\n";
X::sp = {};
v.emplace(v.begin(), std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--insert rvalue no reallocation--\n";
X::sp = {};
v.insert(v.begin(), X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--emplace rvalue no reallocation--\n";
X::sp = {};
v.emplace(v.begin(), X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--insert lvalue reallocation--\n";
X::sp = {};
v.insert(v.begin(), x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace lvalue reallocation--\n";
X::sp = {};
v.emplace(v.begin(), x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--insert xvalue reallocation--\n";
X::sp = {};
v.insert(v.begin(), std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace xvalue reallocation--\n";
X::sp = {};
v.emplace(v.begin(), std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--insert rvalue reallocation--\n";
X::sp = {};
v.insert(v.begin(), X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--emplace rvalue reallocation--\n";
X::sp = {};
v.emplace(v.begin(), X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--push_back lvalue no reallocation--\n";
X::sp = {};
v.push_back(x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace_back lvalue no reallocation--\n";
X::sp = {};
v.emplace_back(x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--push_back xvalue no reallocation--\n";
X::sp = {};
v.push_back(std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace_back xvalue no reallocation--\n";
X::sp = {};
v.emplace_back(std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--push_back rvalue no reallocation--\n";
X::sp = {};
v.push_back(X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(4);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--emplace_back rvalue no reallocation--\n";
X::sp = {};
v.emplace_back(X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--push_back lvalue reallocation--\n";
X::sp = {};
v.push_back(x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace_back lvalue reallocation--\n";
X::sp = {};
v.emplace_back(x);
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--push_back xvalue reallocation--\n";
X::sp = {};
v.push_back(std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
X x{0,0};
std::cout << "--emplace_back xvalue reallocation--\n";
X::sp = {};
v.emplace_back(std::move(x));
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--push_back rvalue reallocation--\n";
X::sp = {};
v.push_back(X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
{
std::vector<X> v;
v.reserve(3);
v.push_back(X(0,0));
v.push_back(X(0,0));
v.push_back(X(0,0));
std::cout << "--emplace_back rvalue reallocation--\n";
X::sp = {};
v.emplace_back(X{0,0});
std::cout << X::sp;
std::cout << "----\n";
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKY2xhc3MgWAp7CiAgICBpbnQgaV87CiAgICBpbnQqIHBfOwoKcHVibGljOgogICAgc3RydWN0IHNwZWNpYWwKICAgIHsKICAgICAgICB1bnNpZ25lZCBjOwogICAgICAgIHVuc2lnbmVkIGR0OwogICAgICAgIHVuc2lnbmVkIGNjOwogICAgICAgIHVuc2lnbmVkIGNhOwogICAgICAgIHVuc2lnbmVkIG1jOwogICAgICAgIHVuc2lnbmVkIG1hOwogICAgfTsKICAgIHN0YXRpYyBzcGVjaWFsIHNwOwoKICAgIFgoaW50IGksIGludCogcCkKICAgICAgICA6IGlfKGkpCiAgICAgICAgLCBwXyhwKQogICAgewovLyAgICAgICAgIHN0ZDo6Y291dCA8PCAiWChpbnQgaSwgaW50KiBwKVxuIjsKICAgICAgICBzcC5jKys7CiAgICB9CgogICAgflgoKQogICAgewovLyAgICAgICAgIHN0ZDo6Y291dCA8PCAiflgoKVxuIjsKICAgICAgICBzcC5kdCsrOwogICAgfQoKICAgIFgoY29uc3QgWCYgeCkKICAgICAgICA6IGlfKHguaV8pCiAgICAgICAgLCBwXyh4LnBfKQogICAgewovLyAgICAgICAgIHN0ZDo6Y291dCA8PCAiWChjb25zdCBYJiB4KVxuIjsKICAgICAgICBzcC5jYysrOwogICAgfQoKICAgIFgmIG9wZXJhdG9yPShjb25zdCBYJiB4KQogICAgewogICAgCiAgICAgICAgaV8gPSB4LmlfOwogICAgICAgIHBfID0geC5wXzsKLy8gICAgICAgICBzdGQ6OmNvdXQgPDwgIlgmIG9wZXJhdG9yPShjb25zdCBYJiB4KVxuIjsKICAgICAgICBzcC5jYSsrOwogICAgICAgIHJldHVybiAqdGhpczsKICAgIH0KCiAgICBYKFgmJiB4KSBub2V4Y2VwdAogICAgICAgIDogaV8oeC5pXykKICAgICAgICAsIHBfKHgucF8pCiAgICB7Ci8vICAgICAgICAgc3RkOjpjb3V0IDw8ICJYKFgmJiB4KVxuIjsKICAgICAgICBzcC5tYysrOwogICAgfQoKICAgIFgmIG9wZXJhdG9yPShYJiYgeCkgbm9leGNlcHQKICAgIHsKICAgIAogICAgICAgIGlfID0geC5pXzsKICAgICAgICBwXyA9IHgucF87Ci8vICAgICAgICAgc3RkOjpjb3V0IDw8ICJYJiBvcGVyYXRvcj0oWCYmIHgpXG4iOwogICAgICAgIHNwLm1hKys7CiAgICAgICAgcmV0dXJuICp0aGlzOwogICAgfQoKfTsKC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Y2soWCgwLDApKTsKICAgICAgICB2LnB1c2hfYmFjayhYKDAsMCkpOwogICAgICAgIHYucHVzaF9iYWNrKFgoMCwwKSk7CiAgICAgICAgWCB4ezAsMH07CiAgICAgICAgc3RkOjpjb3V0IDw8ICItLWVtcGxhY2VfYmFjayBsdmFsdWUgcmVhbGxvY2F0aW9uLS1cbiI7CiAgICAgICAgWDo6c3AgPSB7fTsKICAgICAgICB2LmVtcGxhY2VfYmFjayh4KTsKICAgICAgICBzdGQ6OmNvdXQgPDwgWDo6c3A7CiAgICAgICAgc3RkOjpjb3V0IDw8ICItLS0tXG4iOwogICAgfQogICAgewogICAgICAgIHN0ZDo6dmVjdG9yPFg+IHY7CiAgICAgICAgdi5yZXNlcnZlKDMpOwogICAgICAgIHYucHVzaF9iYWNrKFgoMCwwKSk7CiAgICAgICAgdi5wdXNoX2JhY2soWCgwLDApKTsKICAgICAgICB2LnB1c2hfYmFjayhYKDAsMCkpOwogICAgICAgIFggeHswLDB9OwogICAgICAgIHN0ZDo6Y291dCA8PCAiLS1wdXNoX2JhY2sgeHZhbHVlIHJlYWxsb2NhdGlvbi0tXG4iOwogICAgICAgIFg6OnNwID0ge307CiAgICAgICAgdi5wdXNoX2JhY2soc3RkOjptb3ZlKHgpKTsKICAgICAgICBzdGQ6OmNvdXQgPDwgWDo6c3A7CiAgICAgICAgc3RkOjpjb3V0IDw8ICItLS0tXG4iOwogICAgfQogICAgewogICAgICAgIHN0ZDo6dmVjdG9yPFg+IHY7CiAgICAgICAgdi5yZXNlcnZlKDMpOwogICAgICAgIHYucHVzaF9iYWNrKFgoMCwwKSk7CiAgICAgICAgdi5wdXNoX2JhY2soWCgwLDApKTsKICAgICAgICB2LnB1c2hfYmFjayhYKDAsMCkpOwogICAgICAgIFggeHswLDB9OwogICAgICAgIHN0ZDo6Y291dCA8PCAiLS1lbXBsYWNlX2JhY2sgeHZhbHVlIHJlYWxsb2NhdGlvbi0tXG4iOwogICAgICAgIFg6OnNwID0ge307CiAgICA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