CRTP(curiously repeating template pattern)虽然使用继承,但是它表现的不是```is-a``的关系,而是对接口的扩展
template <typename T>
struct Par {
std::string add() {
T &t{
static_cast<T&>(*this
本文探讨了C++中的CRTP模式,它并非传统的```is-a```继承关系,而是用于接口扩展。同时,介绍了mixin模式,该模式让原类保持不变,由接口类继承原类。
CRTP(curiously repeating template pattern)虽然使用继承,但是它表现的不是```is-a``的关系,而是对接口的扩展
template <typename T>
struct Par {
std::string add() {
T &t{
static_cast<T&>(*this
288
207
1152

被折叠的 条评论
为什么被折叠?
