Re: Making use of move semantics?



On 21 May 2017 at 10:36, Daniel Boles wrote:
I still occasionally find myself reflexively std::move()ing strings into glibmm/gtkmm functions that I unconsciously see as taking ownership of their arguments - only to realise it makes no difference because all of them take strings as const&.

This made me wonder whether there are any cases where, if the user instructs so by using std::move(), glibmm/gtkmm functions could steal the string [ or at least it's c_str() ] and thus avoid having to copy it. All those copies quickly add up to a lot.

You can't steal the contents of a std::string without access to its internals, which only the standard library has. You can't steal the c_str() ... I'm not even sure what that would mean.
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]