mpd/src/util/OffsetPointer.hxx
2023-03-06 14:59:48 +01:00

25 lines
532 B
C++

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
#pragma once
#include <cstddef>
/**
* Offset the given pointer by the specified number of bytes.
*/
constexpr void *
OffsetPointer(void *p, std::ptrdiff_t offset) noexcept
{
return static_cast<std::byte *>(p) + offset;
}
/**
* Offset the given pointer by the specified number of bytes.
*/
constexpr const void *
OffsetPointer(const void *p, std::ptrdiff_t offset) noexcept
{
return static_cast<const std::byte *>(p) + offset;
}