2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
// author: Max Kellermann <max.kellermann@gmail.com>
|
2018-08-20 13:46:18 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-03-13 00:46:28 +01:00
|
|
|
#include <cstddef>
|
2018-08-20 13:46:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset the given pointer by the specified number of bytes.
|
|
|
|
*/
|
2019-01-21 21:19:09 +01:00
|
|
|
constexpr void *
|
2020-09-28 12:16:07 +02:00
|
|
|
OffsetPointer(void *p, std::ptrdiff_t offset) noexcept
|
2018-08-20 13:46:18 +02:00
|
|
|
{
|
2022-06-08 20:50:04 +02:00
|
|
|
return static_cast<std::byte *>(p) + offset;
|
2018-08-20 13:46:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset the given pointer by the specified number of bytes.
|
|
|
|
*/
|
2019-01-21 21:19:09 +01:00
|
|
|
constexpr const void *
|
2020-09-28 12:16:07 +02:00
|
|
|
OffsetPointer(const void *p, std::ptrdiff_t offset) noexcept
|
2018-08-20 13:46:18 +02:00
|
|
|
{
|
2022-06-08 20:50:04 +02:00
|
|
|
return static_cast<const std::byte *>(p) + offset;
|
2018-08-20 13:46:18 +02:00
|
|
|
}
|