2015-12-08 04:51:55 +08:00
|
|
|
#pragma once
|
2015-07-31 18:35:46 +08:00
|
|
|
|
|
|
|
// a helper class for implementing static casting to a derived class using the
|
|
|
|
// curiously recurring template pattern
|
|
|
|
|
|
|
|
template <class Derived>
|
2015-08-30 07:12:46 +08:00
|
|
|
struct Crtp
|
2015-07-31 18:35:46 +08:00
|
|
|
{
|
|
|
|
Derived& derived()
|
|
|
|
{
|
|
|
|
return *static_cast<Derived*>(this);
|
|
|
|
}
|
|
|
|
};
|