is foo an lvalue? Yes. A primary expression that designates a function is an lvalue. However, in some contexts, the function is implicitly converted to a pointer; that pointer is a prvalue (or just an rvalue, before C++11). is foo() an lvalue? Yes. The value of a function call...

*this is never an rvalue but in this case, it is (a reference to) a temporary. Temporaries are valid objects until the statement where they are defined is completed, i.e. until the code reaches the terminating ;, or until the end of the controlling expression for for, if, while, do,...

If z is converted to int, the lvalue-to-rvalue conversion has already been applied, and the result is a prvalue, not an lvalue. One example of ?: where the two operands have different types, but the result is an lvalue, is when one is const-qualified and the other isn't: const int...

You can't assign raw arrays. You need to copy the contents. Assuming your class teacher forces you to use char arrays, you can for example use strncpy to copy the characters: strncpy(_name, name, MAX_NAME_LENGTH); You need to #include <cstring> for this. If your class teacher allows it, better use std::array<char,MAX_NAME_LENGTH>...

Once an entity has a name, it is clearly an lvalue! If you have a name for an rvalue reference, the entity with the name is not an rvalue but an lvalue. The entire point is that you know that this entity references an rvalue and you can legitimately move...

When you return node* from getnext(), you create a temporary variable of node* type, so it has no sense to take its address by using &, this temporary variable will anyway be destroyed soon. When you directly access next, you refer to a long-living variable, and you can take its...

It seems that you mean the following while (y != NULL && x == y->right) ^^^ As for the meaning of the error message then when you use the assignment operator then its priority is less than the priorities of equality and logical operators and you have in fact while...

As far as I understand, Args here could either be lvalue or rvalue references, depending on the type deduction at compile time. You're half right. Args&& would be either an lvalue or value reference. But Args itself is either an lvalue reference or not a reference. A simpler case:...

auto bar = foo{f}; auto is deduced as foo. Subsequently, your definition is equivalent to foo bar = foo{f}; You are trying to create an object of type foo that is copy-initialized with the prvalue foo{f}. The problem is that the copy constructor of foo has a non-const lvalue reference...

Implement getElement() like this: void ** getElement(void ** ppv, size_t index) { return ppv + index; } And use it like this: *getElement(test, 2) = &testThing; If you'd use a macro you could even go the way you intended: #define GET_ELEMENT(ppv, index) \ (*(ppv + index)) Use it like this:...

This is one of the most common "rules of thumb" used to explain what is the difference between lvalues and rvalues. The situation in C++ is much more complex than that so this can't be nothing but a rule of thumb. I'll try to resume a couple of concepts and...

The localtime function requires an argument of type time_t*, a pointer to a time_t object. In your current code, you don't have a time_t object, so you can't create a valid pointer to such an object. Define a local time_t object, initialized to the (converted) value of timeout, and pass...

Neither the string literal nor s are pointers (they are arrays), so the relevant section of the standard is [conv.array]: An lvalue or rvalue of type "array of N T" or "array of unknown bound of T" can be converted to a prvalue of type "pointer to T". The result...

The relevant part of the standard is in [class.temporary] (§12.2/5in N4140): A temporary bound to a reference parameter in a function call (5.2.2) persists until the completion of the full-expression containing the call. So the temporary value_type() will be bound to val and will persist for the duration of the...

Seems to be an issue with the compiler. gcc 4.6.3 is quite old; notice it still has to use c++0x instead of c++11. With a more recent version (4.9.2 in particular), the code compiles and runs just fine.