On Thu, 18 Jul 2013 00:27:37 -0700, Dave Abrahams wrote:
on Wed Jul 17 2013, Daryle Walker
wrote: Date: Wed, 17 Jul 2013 22:09:08 -0500 From: plong@packetizer.com
For example, the following snippet prints "hello, goodbye".
char c[BUFSIZ] = "hello"; istringstream iss(c); strcpy(c, "goodbye"); cout << iss.str() << ", " << c;
However, the library I'm working on doesn't copy. Instead, pointers are passed in and out. So, for example, this code prints "goodbye, goodbye".
char c[BUFSIZ] = "hello"; ibitstream ibs(c); strcpy(c, "goodbye"); cout << ibs.data() << ", " << c;
Copy or don't copy?
I would suggest copying.
But when the source is an rvalue, move instead. That handles the efficiency issues.
I don't understand? Can you elaborate? Wouldn't a move also require that bytes get copied? Also how does one write code that is overloaded for rvalues vs lvalues? Paul