Commit d8558a3a authored by Max Kellermann's avatar Max Kellermann

util/Cast: add "const" overload

parent 72eedb1c
......@@ -93,4 +93,17 @@ ContainerCast(A &a, A C::*member)
return *OffsetCast<C, A>(&a, ContainerAttributeOffset<C, A>(member));
}
/**
* Cast the given pointer to a struct member to its parent structure.
*/
template<class C, class A>
#if defined(__clang__) || GCC_CHECK_VERSION(4,7)
constexpr
#endif
static inline const C &
ContainerCast(const A &a, A C::*member)
{
return *OffsetCast<const C, const A>(&a, ContainerAttributeOffset<C, A>(member));
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment