Re: "Not really an lvalue" warnings
Re: "Not really an lvalue" warnings
- Subject: Re: "Not really an lvalue" warnings
- From: Steve Checkoway <email@hidden>
- Date: Fri, 06 Apr 2007 15:32:11 -0700
Marshall Clow wrote:
This expression:
static_cast<const char *>(typeOfQ)
is not a variable, it is a expression.
Think of the difference between 'x' and '3' - one can be assigned to,
the other cannot )
Googling for "rvalue" and "lvalue" will give more general information.
The left hand side of an assignment need only be an lvalue, not just a
variable. For example:
int &foo();
void bar()
{
foo() = 5;
}
is valid since the expression foo() is a valid lvalue.
Peter O'Gorman wrote:
> put the cast on the right hand side of the assignment.
Actually, putting the static_cast on the right hand side should fail
since const char * cannot be cast to char * without const_cast.
You can put a const_cast<char *> on the right hand side or a
const_cast<const char *&> on the left hand side (but that looks strange).
Mark Wagner wrote:
> I know the difference between an lvalue and an rvalue. My
> understanding is that "static_cast<const char *>(typeOfQ)" is
> functionally and semantically equivalent to "(const char *)typeOfQ"
> with the addition of compile-time checking to make sure the conversion
> is defined.
That's just it, the conversion char * -> const char * isn't defined for
lvalues, at least not without explicitly throwing away the constness via
const_cast.
--
Steve Checkoway
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden