Here is the sample code:
using namespace std;
struct A {
A(unique_ptr<int> s)
: _s(move(s)){}
unique_ptr<int> _s;
};
int main(int argc, const char * argv[]) {
auto&& ptr = make_unique<int>(5);
A a{ptr}; // Error
A b{move(ptr)}; // OK
return 0;
}
My first guess was it should work without using 'move', but I get 'Call to implicitly deleted copy constructor' on clang. Perhaps the type of 'ptr' is not rvalue (strangely?)? Could someone clarify on this?