Can virtual functions be constexpr?

后端 未结 3 1791
旧巷少年郎
旧巷少年郎 2021-02-13 02:46

Can virtual functions like X::f() in the following code

struct X 
{
    constexpr virtual int f() const 
    {
        return 0;
    }
};

3条回答
  •  悲&欢浪女
    2021-02-13 03:24

    Can virtual functions be constexpr?

    Yes. Only since C++20, virtual functions can be constexpr.

提交回复
热议问题