Код: Выделить всё
//Compiled with clang++ -std=c++2a; clang version 5.0.0
#include
#include
#include
struct A {
std::unique_ptr m = std::make_unique(11);
A(A&& a): m(std::move(a.m)) {}
A() {}
};
struct B {
std::shared_ptr m = std::make_shared(11);
};
template
void use_any_ptr() {
std::any a{new T{}};
std::cout m)
Подробнее здесь: [url]https://stackoverflow.com/questions/46852168/stdany-for-objects-that-cant-be-copy-constructed[/url]
Мобильная версия