boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
96 stars 116 forks source link

Can't std::move small_vector with move-only type #233

Closed JVApen closed 1 year ago

JVApen commented 1 year ago

Code on Compiler Explorer:

#include <boost/container/small_vector.hpp>
#include <memory>

struct C
{
    C(int);
    ~C() = default;

    C(const C &) = delete;
    C(C &&) noexcept = default;
    C &operator=(const C &)= delete;
    C &operator=(C &&)= delete;
};

using V = boost::container::small_vector<C, 1>;

auto f(V &&v) 
{
    return std::make_shared<V>(std::move(v));
}

Error:

 error: overload resolution selected deleted operator '='
      *r = *f;
      ~~ ^ ~~

Within a move constructor, I don't expect operator= to be used, as it should only be calling the move constructor of the class.

igaztanaga commented 1 year ago

Many thanks for the report!