On 22 May 2017 at 11:23, Jonathan Wakely <gt...@kayari.org> wrote: > 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. >
Saying "steal" was partly just my hamfisted way of explaining what the move constructor of an std::string (or Glib::ustring) would do. But yeah, partly I was half asleep, and imagining that maybe a C API could grab the char* from a std::string or whatever and leave it in a 'moved-from' kinda condition. Which is nonsense like you said, since there's no API for anything like that.
_______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list