memgraph/include/utils/crtp.hpp

19 lines
355 B
C++
Raw Normal View History

#pragma once
// a helper class for implementing static casting to a derived class using the
// curiously recurring template pattern
template <class Derived>
struct Crtp
{
Derived& derived()
{
return *static_cast<Derived*>(this);
}
2016-02-21 00:53:09 +08:00
const Derived& derived() const
{
return *static_cast<const Derived*>(this);
}
};