#include <memory>
#include <type_traits>
template<typename T>
class Container {
T t;
public:
Container() = default;
template<typename U = void>
Container(const Container& other) : t(other.t) {}
template<typename U = void>
Container(Container&& other) : t(std::move(other.t)) {}
};
static_assert(std::is_copy_constructible<Container<int>>::value, "Non-Copyable");
static_assert(!std::is_copy_constructible<Container<std::unique_ptr<int>>>::value, "Copyable");
Container<std::unique_ptr<int>> makeNonCopyableContainer() {
return Container<std::unique_ptr<int>>();
}
int main () {
Container<int> c1;
Container<int> c2(c1);
Container<std::unique_ptr<int>> c3;
// This would generate compile error:
// Container<std::unique_ptr<int>> c4(c3);
Container<std::unique_ptr<int>> c5(makeNonCopyableContainer());
return 0;
}
I2luY2x1ZGUgPG1lbW9yeT4KI2luY2x1ZGUgPHR5cGVfdHJhaXRzPgoKdGVtcGxhdGU8dHlwZW5hbWUgVD4KY2xhc3MgQ29udGFpbmVyIHsKCVQgdDsKcHVibGljOgogICAgQ29udGFpbmVyKCkgPSBkZWZhdWx0OwoKICAgIHRlbXBsYXRlPHR5cGVuYW1lIFUgPSB2b2lkPgogICAgQ29udGFpbmVyKGNvbnN0IENvbnRhaW5lciYgb3RoZXIpIDogdChvdGhlci50KSB7fQogICAgCiAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBVID0gdm9pZD4KICAgIENvbnRhaW5lcihDb250YWluZXImJiBvdGhlcikgOiB0KHN0ZDo6bW92ZShvdGhlci50KSkge30KfTsKCnN0YXRpY19hc3NlcnQoc3RkOjppc19jb3B5X2NvbnN0cnVjdGlibGU8Q29udGFpbmVyPGludD4+Ojp2YWx1ZSwgIk5vbi1Db3B5YWJsZSIpOwpzdGF0aWNfYXNzZXJ0KCFzdGQ6OmlzX2NvcHlfY29uc3RydWN0aWJsZTxDb250YWluZXI8c3RkOjp1bmlxdWVfcHRyPGludD4+Pjo6dmFsdWUsICJDb3B5YWJsZSIpOwoKQ29udGFpbmVyPHN0ZDo6dW5pcXVlX3B0cjxpbnQ+PiBtYWtlTm9uQ29weWFibGVDb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