lvalue

What are the uses of lvalue subroutines in Perl?

I don't understand what could be the uses of lvalue subroutines? What is it that I can't accomplish with normal subroutines? Could you please post some examples? Thanks ...

Why are C++0x rvalue reference not the default?

One of the cool new features of the upcoming C++ standard, C++0x, are "rvalue references." An rvalue reference is similar to an lvalue (normal) reference, except that it can be bound to a temporary value (normally, a temporary can only be bound to a const reference): void FunctionWithLValueRef(int& a) {...} void FunctionWithRValueRef(in...

lvalue return expressions in Spidermonkey Javascript

Here's an interesting question that could provide useful input into the Spidermonkey flavor of Javascript (used in Firefox & other programs)... The original was in a post on mozilla.dev.tech.js-engine but i'll quote here as well: Newsgroups: mozilla.dev.tech.js-engine From: Brendan Eich <[email protected]> Date: Fri, 7 Aug 2009 12...

Binding temporary to a lvalue reference

I have the following code string three() { return "three"; } void mutate(string& ref) { } int main() { mutate(three()); return 0; } You can see I am passing three() to mutate method. This code compiles well. My understanding is, temporaries can't be assigned to non-const references. If yes, how this program is compiling...

"l-value required" error

When do we get "l-value required" error...while compiling C++ program???(i am using VC++ ) ...

binding lvalue to a reference

Hello everyone, I think I am missing smth back in my theoretical background on this thing. I know there were similar posts but I still do not get it. I have such a code: void somefunc1(Word &Key) { somefunc2(Key); } void somefunc2(char &char1) { return; } compiler generates me an error here: somefunc2(Key); [BCC32 Error]...

l-value substr method in C++

I want to create a substr method in C++ in a string class that I made. The string class is based on C-style string of course, and I take care of the memory management. I want to write a substr(start, length) function that can work on the regular way: CustomString mystring = "Hello"; cout << mystring.substr(0,2); // will print "He" ...

Are Arrays as lvalues in JavaScript ECMAScript-compliant?

Firefox 3.5.3 (at least) allows me to write code like : var array = [4, 5, 6]; var foo, bar, baz; [foo, bar, baz] = array; at which point foo => 4 bar => 5 baz => 6 which can be quite helpful for code clarity. Is that considered ECMAScript-compliant? I didn't see anything in the specification, but JSLint returns an error. ...

lvalue and rvalue

Just wonder if a literal string is a lvalue or a rvalue. Are other literals (like for int, float, char etc) lvalue or rvalue? Is the return value of a function a lvalue or rvalue? How do you tell the difference? ...

Does "LValue" not mean what I think it means?

In the following code: _imageView.hasHorizontalScroller = YES; _imageView.hasVerticalScroller = YES; _imageView.autohidesScrollers = YES; NSLog(@"scrollbar? H %p V %p hide %p", &(_imageView.hasHorizontalScroller), &(_imageView.hasVerticalScroller), &(_imageView.autohidesScrollers)); I'm getting the error: Contro...

Is a member of an rvalue structure an rvalue or lvalue?

A function call returning a structure is an rvalue expression, but what about its members? This piece of code works well with my g++ compiler, but gcc gives a error saying "lvalue required as left operand of assignment": struct A { int v; }; struct A fun() { struct A tmp; return tmp; } int main() { fun().v = 1; } gcc...

PODs, non-PODs, rvalue and lvalues

Could anyone explain the details in terms of rvalues, lvalues, PODs, and non-PODs the reason why the first expression marked below is not ok while the second expression marked below is ok? In my understanding both int() and A() should be rvalues, no? struct A {}; int main() { int i; A a; int() = i; //Not OK (error). A() = a;...

Reference initialization in C++

Hi, Can anybody explain to me why there is a difference between these two statements? class A{}; const A& a = A(); // correct A& b = A(); // wrong It says invalid initialization of non-const reference of type A& from a temporary of type A Why does const matter here? ...

How can I make this function act like an l-value?

Why can't I use the function ColPeekHeight() as an l-value? class View { public: int ColPeekHeight(){ return _colPeekFaceUpHeight; } void ColPeekHeight( int i ) { _colPeekFaceUpHeight = i; } private: int _colPeekFaceUpHeight; }; ... { if( v.ColPeekHeight() > 0.04*_heightTable ) v.ColPeekHei...

Using a Function returning apointer as LValue

Why cant I used a function returning a pointer as a lvalue? For example this one works int* function() { int* x; return x; } int main() { int* x = function(); x = new int(9); } but not this int* function() { int* x; return x; } int main() { int* x; function() = x; } While I can use a pointer variab...

C++0x rvalue references - lvalues-rvalue binding

This is a follow-on question to http://stackoverflow.com/questions/2748866/c0x-rvalue-references-and-temporaries In the previous question, I asked how this code should work: void f(const std::string &); //less efficient void f(std::string &&); //more efficient void g(const char * arg) { f(arg); } It seems that the move overload...

how to assign to the names() attribute of the value of a variable in R

In R, "assign('x',v)" sets the object whose name is 'x' to v. Replace 'x' by the result of applying a text function to a variable x. Then "assign" shows its worth. Unfortunately, "assign(paste('names(','x',')',sep=''),v)" fails. So if 'x' is a variable x, I can set its value, but I can't give it names for its elements. Can one work ...

Rvalues in C++03

How can you tell whether or not a given parameter is an rvalue in C++03? I'm writing some very generic code and am in need of taking a reference if possible, or constructing a new object otherwise. Can I overload to take by-value as well as by-reference and have the rvalue returns call the by-value function? Or do I have a very sickenin...

Objective C - Lvalue required as left operand of assignment

Hi, I get the error (Lvalue required as left operand of assignment) for this code: [[addAlertViewController alertsArray] = [NSMutableArray arrayWithObjects:nil] retain]; How can I fix it? ...

Passing temporaries as LValues

Hello I'd like to use the following idiom, that I think is non-standard. I have functions which return vectors taking advantage of Return Value Optimization: vector<T> some_func() { ... return vector<T>( /* something */ ); } Then, I would like to use vector<T>& some_reference; std::swap(some_reference, some_func()); but so...