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>
|
2017-02-18 18:54:37 +08:00
|
|
|
struct Crtp {
|
|
|
|
Derived& derived() { return *static_cast<Derived*>(this); }
|
2016-02-21 00:53:09 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
2015-07-31 18:35:46 +08:00
|
|
|
};
|