通过什么来替换缺失的行以使此 CRTP 解决方案正常工作?
template<class Crtp> class Base
{
public:
inline Crtp& operator=(const Base<Crtp>& rhs)
{
for (unsigned int i = 0; i < const_size; ++i) {
_data[i] = rhs._data[i];
}
return /* SOMETHING HERE BUT WHAT ? */
}
protected:
static const unsigned int const_size = 10;
double _data[const_size];
};
class Derived : public Base<Derived>
{
};
其他问题:您将提供的解决方案在运行时是否有成本(与直接在派生类中实现运算符的解决方案相比)?
非常感谢你。