#include <utility>
#include <new>
using std::move;
template <typename T>
class container
{
public:
void add(T const & val)
{
obj_.~T(); // ignore this shit
new (&obj_) T{val}; // force to use cctor
}
void add(T && val)
{
obj_.~T();
new (&obj_) T{move(val)}; // force to use mctor
}
private:
T obj_;
};
struct moveable
{
moveable() = default;
moveable(moveable const &) = delete;
moveable(moveable &&) = default;
};
int main()
{
container<moveable> c;
c.add(moveable{});
}
I2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxuZXc+Cgp1c2luZyBzdGQ6Om1vdmU7Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4KY2xhc3MgY29udGFpbmVyCnsKcHVibGljOgogICAgdm9pZCBhZGQoVCBjb25zdCAmIHZhbCkKICAgIHsKICAgICAgICBvYmpfLn5UKCk7ICAgICAgICAgICAgICAgICAgLy8gaWdub3JlIHRoaXMgc2hpdAogICAgICAgIG5ldyAoJm9ial8pIFR7dmFsfTsgICAgICAgICAvLyBmb3JjZSB0byB1c2UgY2N0b3IKICAgIH0KCiAgICB2b2lkIGFkZChUICYmIHZhbCkKICAgIHsKICAgICAgICBvYmpfLn5UKCk7CiAgICAgICAgbmV3ICgmb2JqXykgVHttb3ZlKHZhbCl9OyAgICAvLyBmb3JjZSB0byB1c2UgbWN0b3IKICAgIH0KCnByaXZhdGU6CiAgICBUIG9ial87Cn07CgpzdHJ1Y3QgbW92ZWFibGUKewogICAgbW92ZWFibGUoKSA9IGRlZmF1bHQ7CiAgICBtb3ZlYWJsZShtb3ZlYWJsZSBjb25zdCAmKSA9IGRlbGV0ZTsKICAgIG1vdmVhYmxlKG1vdmVhYmxlICYmKSA9IGRlZmF1bHQ7Cn07CgppbnQgbWFpbigpCnsKICAgIGNvbnRhaW5lcjxtb3ZlYWJsZT4gYzsKICAgIGMuYWRkKG1vdmVhYmxle30pOwp9Cg==