pointer: add align overload for pointer-views

This commit is contained in:
Danny Robson 2018-03-02 12:15:43 +11:00
parent 35537b07ca
commit 89a28322ad

View File

@ -17,6 +17,8 @@
#ifndef CRUFT_UTIL_POINTER_HPP
#define CRUFT_UTIL_POINTER_HPP
#include "view.hpp"
#include <cstddef>
#include <cstdint>
@ -37,6 +39,18 @@ namespace util {
}
///////////////////////////////////////////////////////////////////////////
template <typename ValueT>
constexpr util::view<ValueT*>
align (util::view<ValueT*> value, size_t alignment)
{
return {
align (value.begin (), alignment),
value.end ()
};
}
///------------------------------------------------------------------------
/// round the pointer upwards to satisfy the provided alignment
constexpr inline uintptr_t