Hacker News new | ask | show | jobs
by aw1621107 41 days ago
Looks like it depends on the specific operation(s) you want to perform [0]. For instance, constructing a std::polymorphic<T> from an object of type T or derived from T requires that that object is copy-constructible (among other requirements), but copy-assigning one std::polymorphic<T> to another only requires that T is complete.

[0]: https://eel.is/c++draft/polymorphic

1 comments

Well, https://eel.is/c++draft/polymorphic#assign-2.2 requires copy-constructibility.
Ah, you're right, that's a bad example. I had assumed that that kind of precondition would be explicitly mentioned so I didn't read the rest of the text as closely as I should have.

Perhaps move-assignment would have been a better example? That one at least mentions construction using an rvalue so I think that specific operation would work for move-only types.

Though now that I think about a bit more I suppose it's a bit of a moot point since the constructors all look like they require a copy-constructible T