M
Meal
Is this safe?
foo(C2X(""));
C2X is a macro defined as
#define C2X(str) XStr(str).unicodeForm()
XStr is a kind of string processing class.
unicodeForm() returns pointer of its member string.
When the caller calls foo(C2X("")), a temporary variable XStr(str) is
created, and returns the pointer of its member string as foo's
parameter.
1) Inside of foo, is the pointer still valid?
2) After calling foo, is the pointer still valid?
On VC2003, 1) is valid and 2) is invalid, but I don't know if C++
standard says the same.
foo(C2X(""));
C2X is a macro defined as
#define C2X(str) XStr(str).unicodeForm()
XStr is a kind of string processing class.
unicodeForm() returns pointer of its member string.
When the caller calls foo(C2X("")), a temporary variable XStr(str) is
created, and returns the pointer of its member string as foo's
parameter.
1) Inside of foo, is the pointer still valid?
2) After calling foo, is the pointer still valid?
On VC2003, 1) is valid and 2) is invalid, but I don't know if C++
standard says the same.