Feature #818
Add class for CRTP
0%
Beschreibung
Curiously Recurring Template Pattern: statischen Polymorphismus
#define CRTP_METHOD(name, args...) \
void name() \
{ \
derived().name##_impl( , ##args ); \
}
// VA_ARGS
#define CRTP_HELPERS(Derived) \
Derived& derived() \
{ \
return static_cast<Derived&>(*this); \
} \
\
const Derived& derived() const \
{ \
return static_cast<const Derived&>(*this); \
}
template<class Derived>
class CClassA
{
CRTP_HELPERS(Derived);
public:
CRTP_METHOD(name, int i1, int i2);
void callback()
{
name();
}
};
class CClassB;
class CClassB :public CClassA < CClassB >
{
public:
void name_impl()
{
printf("Callback\n");
}
};