字符串文字的值类别是什么? [英] What is the value category of string literals?

查看:68
本文介绍了字符串文字的值类别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很确定整数,字符,布尔值和浮点文字的值类别是prvalue。

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.

我不清楚字符串文字。它们的类型为 const charx数组,其中charx是某种字符类型。

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

它在3.10中表示:


文字的值...也是一个prvalue。

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

但是我认为这可能不会

字符串文字的值类别是什么?

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

推荐答案


所以我很确定整数的值类别,

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

是正确的。


字符串文字的值类别是什么?

What is the value category of a string literal?

根据C的第5.1.1 / 1段++ 11标准:

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


文字是主要表达式。其类型取决于其形式(2.14)。 字符串文字是左值;所有其他文字都是prvalue。

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.

这篇关于字符串文字的值类别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆