aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-21 17:13:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-21 17:13:15 +0200
commitae19570ed0194d1cdcfafe83286c2238e86d37f3 (patch)
tree8393b7775abf8a88e644ba2122247c935d0aba71
parentd38ae1f987b5ccdb316fb044c35486ec3be6c029 (diff)
Add support for moving the underlying string out of path
-rw-r--r--butl/path13
1 files changed, 9 insertions, 4 deletions
diff --git a/butl/path b/butl/path
index 865da4e..7f97f49 100644
--- a/butl/path
+++ b/butl/path
@@ -438,6 +438,8 @@ namespace butl
return string_type (*p_, b_, (e_ != string_type::npos ? e_ - b_ : e_));
}
+ pointer operator-> () const = delete;
+
friend bool
operator== (const iterator& x, const iterator& y)
{
@@ -532,10 +534,13 @@ namespace butl
public:
const string_type&
- string () const
- {
- return this->path_;
- }
+ string () const& {return this->path_;}
+
+ // Moves the underlying path string out of the path object. The
+ // path object becomes empty. Usage: std::move (p).string ().
+ //
+ string_type
+ string () && {string_type r; r.swap (this->path_); return r;}
// If possible, return a POSIX representation of the path. For example,
// for a Windows path in the form foo\bar this function will return