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
1.4m articles
1.4m replys
5 comments
57.0k users