util/Cast: fix indent
This commit is contained in:
parent
96abd70c13
commit
e74e1256d4
@ -38,21 +38,21 @@
|
|||||||
static constexpr void *
|
static constexpr void *
|
||||||
OffsetPointer(void *p, ptrdiff_t offset)
|
OffsetPointer(void *p, ptrdiff_t offset)
|
||||||
{
|
{
|
||||||
return (char *)p + offset;
|
return (char *)p + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
static constexpr T *
|
static constexpr T *
|
||||||
OffsetCast(U *p, ptrdiff_t offset)
|
OffsetCast(U *p, ptrdiff_t offset)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<T *>(OffsetPointer(p, offset));
|
return reinterpret_cast<T *>(OffsetPointer(p, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast the given pointer to a struct member to its parent structure.
|
* Cast the given pointer to a struct member to its parent structure.
|
||||||
*/
|
*/
|
||||||
#define ContainerCast(p, container, attribute) \
|
#define ContainerCast(p, container, attribute) \
|
||||||
OffsetCast<container, decltype(((container*)nullptr)->attribute)>\
|
OffsetCast<container, decltype(((container*)nullptr)->attribute)> \
|
||||||
((p), -ptrdiff_t(offsetof(container, attribute)))
|
((p), -ptrdiff_t(offsetof(container, attribute)))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user