From ae19570ed0194d1cdcfafe83286c2238e86d37f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 Aug 2015 17:13:15 +0200 Subject: Add support for moving the underlying string out of path --- butl/path | 13 +++++++++---- 1 file 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 -- cgit v1.1