Apparently, consteval
is going to be a keyword in C++20. The cppreference page for it is currently blank. What is it going to be and how does it relate to constexpr
?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
It declares immediate functions, that is, functions that must be evaluated at compile time to produce a constant. (It used to be spelled
constexpr!
in a previous revision of the paper.) In contrast,constexpr
functions may be evaluated at compile time or run time, and need not produce a constant in all cases.The adopted paper is P1073R3, which is not yet publicly available, but a previous revision is available and the introductory (motivation and high-level description) portion is about the same (except that the "Source Locations" section is deleted in R3).
@geza Yes, you can overload based on consteval-ness! Consider this class:
It only has a consteval constructor, so it can only be constructed from a value known at compile-time. If I overload a function using this class, I can come up with an overload that is only considered if the integer being passed is a constant. See example at https://godbolt.org/z/_drqwB