AMDG On 03/22/2017 11:55 PM, Mikhail Strelnikov via Boost-users wrote:
In following code TypeErasure creates two copies of s, while Boost.Any creates no copies at all.
any x{ s{} }; any y{ std::move(x) };
Boost.TypeErasure tries to be as faithful as possible to normal overload resolution rules. As a result, the move constructor should resolve as follows: If constructible
is present Allocate a new object and call the captured move constructor to initialize it. Else if constructible
is present Allocate a new object and initialize it with the copy constructor. Else Error If relaxed is present, then it would be possible to move the pointer, leaving the source any empty, but this isn't currently implemented.
any z; z = std::move(y);
There is move constructor for type_erasure::any, but it does allocate memory and calls copy constructor for s. Why?
And why there is no move assignment operator in type_erasure::any?
There will be once I get around to merging Deniz' PR. In Christ, Steven Watanabe