Now let's deal with the problem opposite to Section 3.7. In other words, you have a view of another object's data, but you really want a unique copy. In this case, you can use the copy function. Here is a common situation within functions:
void foo(const RWMathArray<double>& v) { RWMathArray<double> myCopy = v.copy(); ... // Now you can play with myCopy's data while // honoring the const modifier of v... } |
In this example, myCopy and v each refer to their own data, and no aliasing takes place.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.