diff options
author | Brad King <brad.king@kitware.com> | 2018-11-08 13:12:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-12-12 13:10:16 (GMT) |
commit | 2d68b2c593b0bc19273e95f98ff29b3d3cff90c7 (patch) | |
tree | 6be15c7acfe6fd77f52ddab42519cd52ad3f1a7d /Source/cmPathLabel.h | |
parent | a0841b59bdacc1e550e6607d9e44e79ae456cd19 (diff) | |
download | CMake-2d68b2c593b0bc19273e95f98ff29b3d3cff90c7.zip CMake-2d68b2c593b0bc19273e95f98ff29b3d3cff90c7.tar.gz CMake-2d68b2c593b0bc19273e95f98ff29b3d3cff90c7.tar.bz2 |
String: Add str_if_stable() as a const alternative to str()
The `str()` method must be non-const because it may need to internally
mutate the representation of the string in order to have an owned
`std::string` instance holding the exact string (not a superstring).
This is inconvenient in contexts where we can ensure that no mutation
is needed to get a `std::string const&`.
Add a `str_if_stable() const` method that returns `std::string const*`
so we can return `nullptr` if if mutation would be necessary to get a
`std::string const&`. Add supporting `is_stable() const` and
`stabilize()` methods to check and enforce stable availability of
`std::string const&`. These can be used to create `String const`
instances from which we can still get a `std::string const&` via
`*str_if_stable()` by maintaining the stability invariant at runtime.
Diffstat (limited to 'Source/cmPathLabel.h')
0 files changed, 0 insertions, 0 deletions