是否在移动后指定任何标准类的状态? [英] Is the state of any standard class after being moved specified?

查看:95
本文介绍了是否在移动后指定任何标准类的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我移动 shared_ptr 'a'变成 shared_ptr

是否在移动后指定了任何标准类的状态?

解决方案

一般来说,17.6.5.15/1适用于:


在C ++标准库中定义的类型对象可以从(12.8)移动。可以显式指定或隐式生成移动操作。除非另有说明,否则此类移动对象应置于有效但未指定的状态。


无前提条件。



如果指定, @Xeo说适用。


If I move shared_ptr 'a' into shared_ptr 'b' is 'a' guaranteed to be null?

Is the state of any standard class after being moved specified?

解决方案

In general 17.6.5.15/1 applies:

Objects of types defined in the C++ standard library may be moved from (12.8). Move operations may be explicitly specified or implicitly generated. Unless otherwise specified, such moved-from objects shall be placed in a valid but unspecified state.

Thus you can call any functions which requires no precondition.

If specified, what @Xeo said applies.

这篇关于是否在移动后指定任何标准类的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆