util/Cast: use std::ptrdiff_t

This commit is contained in:
Max Kellermann 2020-09-28 13:12:53 +02:00 committed by Max Kellermann
parent 4e47653cf6
commit fec80f2835
1 changed files with 5 additions and 5 deletions

View File

@ -37,27 +37,27 @@
template<typename T, typename U>
constexpr T *
OffsetCast(U *p, ptrdiff_t offset)
OffsetCast(U *p, std::ptrdiff_t offset)
{
return reinterpret_cast<T *>(OffsetPointer(p, offset));
}
template<typename T, typename U>
constexpr T *
OffsetCast(const U *p, ptrdiff_t offset)
OffsetCast(const U *p, std::ptrdiff_t offset)
{
return reinterpret_cast<const T *>(OffsetPointer(p, offset));
}
template<class C, class A>
constexpr ptrdiff_t
constexpr std::ptrdiff_t
ContainerAttributeOffset(const C *null_c, const A C::*p)
{
return ptrdiff_t((const char *)&(null_c->*p) - (const char *)null_c);
return std::ptrdiff_t((const char *)&(null_c->*p) - (const char *)null_c);
}
template<class C, class A>
constexpr ptrdiff_t
constexpr std::ptrdiff_t
ContainerAttributeOffset(const A C::*p)
{
return ContainerAttributeOffset<C, A>(nullptr, p);