-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R3.2.8
“不应使用宏定义常量” 中的正确示例可以改进
#49
Comments
好主意~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
原文:
将
const
替换为constexpr
会更加合适。主要是有几点考量:
以
const
修饰的标量类型可以进行非常量初始化,如:以
const
修饰的标量类型,不一定是“常量表达式”,如如果更换为
constexpr
则没有这些问题了。由于关键字复用和 C 语言的缘故,
const
本身的含义不那么明确,它的要求也不是那么严格,如果确定是常量,在 C++ 中应该使用constexpr
。The text was updated successfully, but these errors were encountered: