Can modern C++ get you performance for free?

后端 未结 2 1430
臣服心动
臣服心动 2020-12-07 06:43

It is sometimes claimed that C++11/14 can get you a performance boost even when merely compiling C++98 code. The justification is usually along the lines of move semantics,

2条回答
  •  生来不讨喜
    2020-12-07 07:37

    if you have something like:

    std::vector foo(); // function declaration.
    std::vector v;
    
    // some code
    
    v = foo();
    

    You got a copy in C++03, whereas you got a move assignment in C++11. so you have free optimisation in that case.

提交回复
热议问题