How can I distinguish a variable as a compiler-constructed string?
For example, while the rvalue "Hello, World"
is of type const char*
. const char*
in itself does not mean that a pointer can't be changed. A char* const
pointer can't be changed, but that's not what's constructed by the compiler.
Does this mean that, for any container that holds a const char*
, the data should be copied by means other than C++'s move semantics? Is there any way to just move compiler-constructed strings and leave all other strings alone?
For example, in the GCC 4.5.2, a method that returns the type int
as opposed to int&
is treated as returning int&&
. I don't know if the actual standard is supposed to be this way, but that's what the GCC does for the time being.
Edit: To clarify, I mean that the actual memory that the pointer points to should be copied. This means that new memory has to be allocated and that the data from the pointer should be copied to the new location.