Should a using command issue a warning when using a reserved identifier?

纵然是瞬间 提交于 2019-12-08 15:46:29

问题


When using the line

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

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;

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

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?


回答1:


Arguably, the wording is clear enough on this—[over.literal]/1:

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.

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.



来源:https://stackoverflow.com/questions/41444490/should-a-using-command-issue-a-warning-when-using-a-reserved-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!