会移动任何C++的施工/分配标准库类型在参数上有前提吗?
写对我来说,有点不清楚的是如何从移动价值到C ++标准库中指定的从移动值的移动分配。
如该答案中所述,对于任何可移动的类型,都可以执行此类动作。
使用移动分配运算符为任何标准库类型执行此类动作是否可以?从移动对象的移动构造呢?在标准库中始终有效吗?
我想更容易看到它对指定其移动状态的类型有效,例如eg simel_ptr
,但是那些未指定的类型呢?
换句话说,我想问题是,每个stdlib类型是否具有Move-Ctor MoveContructiford,并且每个具有MOVE-ARSIGN MOVEASENSINGESENSINGESENSINGESENSINGESING的STDLIB类型吗?
While writing this answer I realized that it's a bit unclear to me how is a move-assignment from a moved-from value to a moved-from value specified in C++ standard library.
As mentioned in that answer, for any MoveAssignable type its fine to perform such a move.
Is it fine to perform such a move for any standard library type with a move assignment operator? What about move-construction from a moved-from object? Is it always valid in the standard library?
I guess it's easier to see that it's valid for types that specify their moved-from state, like e.g. unique_ptr
, but what about those that don't specify it?
In other words, I guess the question would be, is every stdlib type that has a move-ctor MoveContructible, and is every stdlib type that has a move-assign MoveAssignable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论