使用保留标识符时

使用保留标识符时

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

问题描述

使用线路时

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

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

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

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?

推荐答案

可以说,在此 [over.literal]/1 :

这可以解释为是指(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命令应该发出警告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:55