[Bug libstdc++/60584] std::vector::emplace_back(...) use move constructor
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 19 13:34:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60584
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|c++ |libstdc++
Resolution|--- |INVALID
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't know what clang does to compile it, but the code is not valid.
vector<T>::emplace_back requires that T is MoveInsertable into the vector. Foo
fails that requirement because it has a deleted copy constructor and deleted
move constructor, because NonCopyable has a user-provided copy constructor
defined as deleted.
If you want NonCopyable to be movable then you need to do this:
class NonCopyable
{
public:
NonCopyable(){}
NonCopyable(const NonCopyable &) = delete;
NonCopyable(NonCopyable &&) = default;
};
With that move constructor the code works.
More information about the Gcc-bugs
mailing list