summaryrefslogtreecommitdiffstats
path: root/Source/cmString.hxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-04 00:08:18 (GMT)
committerBrad King <brad.king@kitware.com>2018-12-12 13:10:15 (GMT)
commit9d5fe8e96a074b6e112d981302c77e31a1bcde00 (patch)
tree9a080e37d2b2d6e111ca958e7d9482ed62083c63 /Source/cmString.hxx
parent80802a002c16249e99c24f62adb8ffbe006b97e0 (diff)
downloadCMake-9d5fe8e96a074b6e112d981302c77e31a1bcde00.zip
CMake-9d5fe8e96a074b6e112d981302c77e31a1bcde00.tar.gz
CMake-9d5fe8e96a074b6e112d981302c77e31a1bcde00.tar.bz2
String: Add 'borrow' member to construct borrowing instances
This will allow creation of `cm::String` instances that borrow from non-owned storage. It is the caller's responsibility to ensure that no copy of the instance outlives the borrowed buffer.
Diffstat (limited to 'Source/cmString.hxx')
-rw-r--r--Source/cmString.hxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/cmString.hxx b/Source/cmString.hxx
index ddafd56..3b59353 100644
--- a/Source/cmString.hxx
+++ b/Source/cmString.hxx
@@ -272,6 +272,10 @@ public:
~String() = default;
+ /** Construct by borrowing an externally-owned buffer. The buffer
+ must outlive the returned instance and all copies of it. */
+ static String borrow(string_view v) { return String(v, Private()); }
+
/** Assign by moving from another String instance.
The other instance is left as a null string. */
String& operator=(String&& s) noexcept