util/Cast: add "const" overload
This commit is contained in:
parent
72eedb1c98
commit
d8558a3af3
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue