From a723f702c2feb92256ff10e6a56326063d4a062e Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 21 Aug 2022 10:57:26 +0200 Subject: Add Glib::ustring::release() Fixes #101 --- glib/glibmm/ustring.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'glib') diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h index 41165f58..3d879be9 100644 --- a/glib/glibmm/ustring.h +++ b/glib/glibmm/ustring.h @@ -22,6 +22,7 @@ #include #include // for std::size_t and optionally std::ptrdiff_t +#include // For std::move() #include #include #include @@ -677,6 +678,10 @@ public: GLIBMM_API inline operator std::string() const; // e.g. std::string str = ustring(); GLIBMM_API inline const std::string& raw() const; + /*! Return the stored string, moved from the %ustring. + * @newin{2,74} + */ + GLIBMM_API inline std::string release(); // Not necessarily an ASCII char*. Use g_utf8_*() where necessary. GLIBMM_API const char* data() const; @@ -1259,6 +1264,12 @@ ustring::raw() const return string_; } +inline std::string +ustring::release() +{ + return std::move(string_); +} + template inline // static ustring -- cgit v1.2.1