Is int & foo (); lvalue?

I know that there may be other similar questions, but they did not quite answer my question.

I looked through some slides from a lecture on type inference C++, and on one of them I found the following statement:

int & foo();           // foo() is lvalue;

At first I thought it was just wrong - it foois a function that cannot be assigned, it is not an lvalue value. But now I think that the author could have something else in mind. Namely, that a function call may be an lvalue, and not the fuction itself.

So in other words:

  • is there an foolvalue?
  • is there an foo()lvalue?
  • can a fuction be assigned ( not a function call ) (i.e. foo = something;)?
  • "lvalue is every object / object that can be assigned" - is this statement always correct and accurate?

The question 4requires a more detailed explanation. With this I am trying to understand what lvalue is. Another definition that I saw says: "lvalues ​​have storage addresses that can be obtained." I'm not sure that the storage address is accurate, but take our function as an example foo- we can definitely get some address of this fuction. This C++is just a function name

foo;   // returns the address of funtion 'foo'

But at the same time, I don’t think we can assign foo(question 3). So is it an lvalue or not?

I would be grateful if you answered all 4 points. I mark this question as C++, rather than C++11, since I believe that this question applies to all versions of the language. However, if there are any differences, indicate them.

+4
1

foo lvalue?

. , , lvalue. ; prvalue ( rvalue, ++ 11).

foo() lvalue?

. - lvalue, lvalue, .

fuction ( )

. .

"lvalue - /, " - ?

. Lvalue - , . , .

+6

All Articles