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

Simon Marchi simon.marchi@polymtl.ca
Wed Jan 25 18:39:00 GMT 2017


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; }




More information about the Gdb-patches mailing list