草庐IT

RefString

全部标签

c++ - 在 C++ 中,如何从方法中返回一个不可变的参数,保持不变且没有拷贝?

在C++中,如何从方法返回一个参数,不改变,没有拷贝?//Thisismoreorlessthedesiredsignaturefromthecaller'spointofviewSomeImmutableObjectManipulateIfNecessary(SomeImmutableObjectconst&existingObject){//Dosomework…//...if(manipulationIsNeccessary){//Returnanewobjectwithnewdataetc(preferablywithoutanothercopy)...returnSomeIm