会移动任何C++的施工/分配标准库类型在参数上有前提吗?

发布于 2025-02-08 23:29:32 字数 505 浏览 0 评论 0原文

对我来说,有点不清楚的是如何从移动价值到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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文