Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm pretty sure the value category of integer, character, boolean and floating point literals is prvalue.

User defined literals are like function calls, so their value category depends on the return type of the operator function they resolve to.

I'm not clear on string literals. They have type "array of const charx" where charx is some character type.

It says in 3.10:

The value of a literal ... is also a prvalue.

But I think this might not apply to string literals?

What is the value category of a string literal? How did you determine this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
377 views
Welcome To Ask or Share your Answers For Others

1 Answer

So I'm pretty sure the value category of integer, character, boolean and floating literals are prvalues.

That's correct.

What is the value category of a string literal?

Per Paragraph 5.1.1/1 of the C++11 Standard:

A literal is a primary expression. Its type depends on its form (2.14). A string literal is an lvalue; all other literals are prvalues.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...