Can virtual functions like X::f() in the following code
X::f()
struct X { constexpr virtual int f() const { return 0; } };
be constexpr?
constexpr
This answer is no longer correct as of C++20.
No. From [dcl.constexpr]/3 (7.1.5, "The constexpr specifier"):
The definition of a constexpr function shall satisfy the following requirements: — it shall not be virtual
The definition of a constexpr function shall satisfy the following requirements:
— it shall not be virtual
2.1m questions
2.1m answers
60 comments
57.0k users