使用保留标识符时,using命令应该发出警告吗? [英] Should a using command issue a warning when using a reserved identifier?

查看:138
本文介绍了使用保留标识符时,using命令应该发出警告吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用线路时

using std::literals::chrono_literals::operator""s;

在g ++ 6.3.0中,编译器发出警告,指出:

in g++ 6.3.0, the compiler issues a warning stating:

警告:保留不带'_'的文字运算符后缀以供将来标准化

warning: literal operator suffixes not preceded by '_' are reserved for future standardization

using std::literals::chrono_literals::operator""s;

在MSVS中也发出了类似的警告.但是,clang 3.8.0不会发出此类警告.

A similar warning is also issued in MSVS. However, clang 3.8.0 issues no such warning.

由于operator""s是由chrono库的标准定义的,因此不应该发出警告,因为我们只是导入名称而未定义名称吗?

Since operator""s is defined by the standard for the chrono library shouldn't this not issue a warning since we are just importing the name and not defining one?

推荐答案

可以说,在此

一些文字后缀标识符是 为将来的标准化保留;参见17.6.4.3.5.声明 literal-operator-id 使用这样的文字后缀 标识符格式错误;无需诊断.

Some literal suffix identifiers are reserved for future standardization; see 17.6.4.3.5. A declaration whose literal-operator-id uses such a literal suffix identifier is ill-formed; no diagnostic required.

这可以解释为是指(UDL运算符)声明,其名称"是 literal-operator-id —当然排除了您的情况,因为 literal-operator- ID 是不合格的. [reserved.names]/2 也是如此,其中上下文是用户定义的文字运算符的声明.

This can be interpreted as referring to (UDL operator) declarations whose "name" is a literal-operator-id—which of course excludes your case, since literal-operator-ids are unqualified. Same goes for [reserved.names]/2, where the “context”s are declarations of user-defined literal operators.

这篇关于使用保留标识符时,using命令应该发出警告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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