Skip to content

Conversation

@jiapengwen
Copy link

No description provided.

Copy link
Owner

@chenshuo chenshuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? What's the benefit?

@jiapengwen
Copy link
Author

constexpr variable is guaranteed to have a value available at compile time. whereas static const members or const variable could either mean a compile time value or a runtime value. Typing constexpr express your intent of a compile time value in a much more explicit way than const.

One more thing, in C++17, constexpr static data member variables will be inline too. That means you can omit the out of line definition of static constexpr variables, but not static const.

@jiapengwen
Copy link
Author

constexpr is more c++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants