This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 5/5] Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy


On 2017-01-25 13:28, Pedro Alves wrote:
If it had been "to std::move the string contents out..." it might have
been a bit clearer, I'm not entirely sure.

That would read a bit odd to me, since "std::move" itself
does nothing, it's just a cast.

I think it's obvious that if you're going to use std::move, it's to move the value somewhere, not just "std::move (buf);" by itself. But if you want to go with the more explicit comment below, it's fine with me. It shows the use case more clearly.

Maybe it'll be clearer with
an example?  Something like:

   /* Accesses the std::string containing the entire output collected
-     so far.  Returns a non-const reference so that it's easy to move
-     the string contents out of the string_file.  */
+     so far.
+
+     Returns a non-const reference so that it's easy to move the
+     string contents out of the string_file.  E.g.:
+
+      string_file buf;
+      buf.printf (....");
+      buf.printf (....");
+      return std::move (buf.string ());
+  */
   std::string &string () { return m_string; }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]