简单测试std::move

std::move(t),用于指示对象 t 可以“被移动”,即允许从 t 到另一对象的有效率的资源传递。

假设将t赋值给t1,即:
t1=std::move(t);

操作完成后,t的值(内容)给了t1,t本身没有值了。

举例:


#include <iostream>
#include <utility>
#include <string>

int main(int argc, const char * argv[]) {

    std::string str1 = "Hello_1";
    std::string str2;

    std::string str3 = "Hello_3";
    std::string str4;

    // 将str1赋值给str2,
    // 将带来复制 str1 的成本
    str2 = str1;
    std::cout << "copy str1 to str2, after copy, str2 is \"" << str2 << "\" and str1 is \"" << str1 << "\"\n\n";

    // 使用std::move
    // 表示不复制字符串;而是
    // str3 的内容被移动到 str4
    // 这个开销比较低,但也意味着 str3 现在将为空。
    str4 = std::move(str3);
    std::cout << "move str3 to str4, after move, str4 is \"" << str4 << "\" and str3 is \"" << str3 << "\"\n\n";

    return 0;
}

运行结果:

copy str1 to str2, after copy, str2 is "Hello_1" and str1 is "Hello_1"

move str3 to str4, after move, str4 is "Hello_3" and str3 is ""

参考

http://zh.cppreference.com/w/cpp/utility/move

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
IEEE Standard for System and Software Verification and Validation IEEE Std 1012-2012 Front Cover -14 Title Page -12 Notice to users -9 Laws and regulations -9 Copyrights -9 Updating of IEEE documents -9 Errata -9 Patents -8 Participants -7 Introduction -5 Contents -3 Important notice 1 1. Overview 1 1.1 Scope 1 1.2 Purpose 2 1.3 Field of application 3 1.4 V&V objectives 4 1.5 Organization of the standard 4 1.6 Audience 6 1.7 Conformance 7 1.8 Disclaimer 7 2. Normative references 7 3. Definitions, abbreviations, and acronyms 7 3.1 Definitions 7 3.2 Abbreviations and acronyms 11 4. Relationships between V&V and life cycle processes 12 5. Integrity levels 15 6. V&V processes overview 17 6.1 General 17 6.2 V&V testing 18 7. Common V&V activities 19 7.1 Activity: V&V Management 19 7.2 Activity: Acquisition Support V&V 20 7.3 Activity: Supply Planning V&V 21 7.4 Activity: Project Planning V&V 21 7.5 Activity: Configuration Management V&V 21 8. System V&V activities 33 8.1 Activity: Stakeholder Requirements Definition V&V 33 The purpose of the Stakeholder Requirements Definition Process is to define the requirements for a system that can provide the services needed by users and other stakeholders in a defined environment. It identifies stakeholders, or stakeholder classes... 33 The V&V effort shall perform, as specified in Table 2b for the selected integrity level, the following Stakeholder Requirements Definition V&V tasks described in Table 1b: 33 8.2 Activity: Requirements Analysis V&V 33 8.3 Activity: Architectural Design V&V 34 8.4 Activity: Implementation V&V 35 8.5 Activity: Integration V&V 35 8.6 Activity: Transition V&V 36 8.7 Activity: Operation V&V 36 8.8 Activity: Maintenance V&V 37 8.9 Activity: Disposal V&V 38 9. Software V&V activities 68 9.1 Activity: Software Concept V&V 68 9.2 Activity: Software Requirements V&V 68 9.3 Activity: Software Design V&V 69 9.4 Activity: Software Construction V&V 69 9.5 Activity: Software Integration Test V&V 70 9.6 Activity: Software Qualification Test V&V 70 9.7 Activity: Software Acceptance Test V&V 71 9.8 Activity: Software Installation and Checkout V&V 71 9.9 Activity: Software Operation V&V 72 9.10 Activity: Software Maintenance V&V 72 9.11 Activity: Software Disposal V&V 73 10. Hardware V&V activities 110 10.1 Activity: Hardware Concept V&V 110 10.2 Activity: Hardware Requirements V&V 110 10.3 Activity: Hardware Design V&V 111 10.4 Activity: Hardware Fabrication V&V 111 10.5 Activity: Hardware Integration Test V&V 112 10.6 Activity: Hardware Qualification Test V&V 112 10.7 Activity: Hardware Acceptance Test V&V 113 10.8 Activity: Hardware Transition V&V 113 10.9 Activity: Hardware Operation V&V 114 10.10 Activity: Hardware Maintenance V&V 114 10.11 Activity: Hardware Disposal V&V 115 11. V&V reporting, administrative, and documentation requirements 147 11.1 V&V reporting requirements 147 11.2 V&V administrative requirements 150 11.3 V&V documentation requirements 150 12. V&V plan outline 151 12.1 Overview 151 12.2 VVP Section 1: Purpose 152 12.3 VVP Section 2: Referenced documents 152 12.4 VVP Section 3: Definitions 152 12.5 VVP Section 4: V&V overview 152 12.5.1 VVP Section 4.1: Organization 152 12.5.2 VVP Section 4.2: Master schedule 153 12.5.3 VVP Section 4.3: Integrity level scheme 153 12.5.4 VVP Section 4.4: Resources summary 153 12.5.5 VVP Section 4.5: Responsibilities 153 12.5.6 VVP Section 4.6: Tools, techniques, and methods 153 12.6 VVP Section 5: V&V processes 154 12.6.1 VVP Section 5.1: Common V&V Processes, Activities, and Tasks 154 12.6.2 VVP Section 5.2: System V&V Processes, Activities, and Tasks 154 12.6.3 VVP Section 5.3: Software V&V Processes, Activities, and Tasks 154 12.6.4 VVP Section 5.4: Hardware V&V Processes, Activities, and Tasks 154 12.7 VVP Section 6: V&V reporting requirements 154 12.8 VVP Section 7: V&V administrative requirements 154 12.8.1 General 154 12.8.2 VVP Section 7.1: Anomaly resolution and reporting 154 12.8.3 VVP Section 7.2: Task iteration policy 154 12.8.4 VVP Section 7.3: Deviation policy 155 12.8.5 VVP Section 7.4: Control procedures 155 12.8.6 VVP Section 7.5: Standards, practices, and conventions 155 12.9 VVP Section 8: V&V test documentation requirements 155 Annex A (informative) Mapping of IEEE 1012 V&V activities and tasks 156 A.1 Mapping of ISO/IEC 15288 V&V requirements to IEEE 1012 V&V activities and tasks 156 A.2 Mapping of IEEE 1012 V&V activities to ISO/IEC 15288 system life cycle processes and activities 158 A.3 Mapping of ISO/IEC 12207 V&V requirements to IEEE 1012 V&V activities and tasks 159 A.4 Mapping of IEEE 1012 V&V activities to IEEE 12207 software life cycle processes and activities 161 Annex B (informative) A risk-based, integrity-level scheme 163 Annex C (informative) Definition of independent V&V (IV&V) 165 C.1 Technical independence 165 C.2 Managerial independence 165 C.3 Financial independence 165 C.4 Forms of independence 165 C.4.1 Classical IV&V 166 C.4.2 Modified IV&V 166 C.4.3 Integrated IV&V 166 C.4.4 Internal IV&V 166 C.4.5 Embedded V&V 167 Annex D (informative) V&V of reuse software 168 D.1 Purpose 168 D.2 V&V of software developed in a reuse process 169 D.2.1 V&V of assets in development 169 D.2.2 V&V of reused assets 169 D.3 V&V of software developed and reused outside of a reuse process 169 Annex E (informative) V&V measures 175 E.1 Introduction 175 E.2 Measures for evaluating anomaly density 175 E.3 Measures for evaluating V&V effectiveness 176 E.4 Measures for evaluating V&V efficiency 176 Annex F (informative) Example of V&V relationships to other project responsibilities 178 Annex G (informative) Optional V&V tasks 179 Annex H (informative) Environmental factors considerations 185 H.1 Introduction 185 H.2 In the agreement processes 185 H.3 In the organizational project-enabling processes 185 H.4 In the project processes 186 H.5 In the technical processes 186 Annex I (informative) V&V of system, software, and hardware integration 188 I.1 Introduction 188 I.2 Examples of system failures caused by integration issues 188 I.2.1 Year 2000 System Integration Issue 189 I.2.2 System architecture integration issues 189 I.3 System, software, and hardware interaction issues 190 Annex J (informative) Hazard, security, and risk analyses 193 J.1 Hazard analysis 193 Annex K (informative) Example of assigning and changing the system integrity level of “supporting system functions” 198 Annex L (informative) Mapping of ISO/IEC/IEEE 15288 and IEEE 12207 process outcomes to V&V tasks 200 Annex M (informative) Bibliography 209

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值