Initializing a static constexpr from an incomplete type because of a template base class

后端 未结 2 2088
[愿得一人]
[愿得一人] 2020-12-06 20:25

I have a template base class, whereby subclasses are expected to pass themselves as the template parameter.

It looks a little like this:

template<         


        
2条回答
  •  太阳男子
    2020-12-06 21:05

    You can simply add constexpr to the definition of LIFE:

    constexpr Derived Derived::LIFE = Derived(42);
    

    Until recently GCC had a bug where it rejected this; you'll need to use either Clang or GCC 4.9.

提交回复
热议问题