From 89a28322ad519ef3549af7ed6287d6f70cfdee6c Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 2 Mar 2018 12:15:43 +1100 Subject: [PATCH] pointer: add align overload for pointer-views --- pointer.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pointer.hpp b/pointer.hpp index bd55ccfc..0d39e035 100644 --- a/pointer.hpp +++ b/pointer.hpp @@ -17,6 +17,8 @@ #ifndef CRUFT_UTIL_POINTER_HPP #define CRUFT_UTIL_POINTER_HPP +#include "view.hpp" + #include #include @@ -37,6 +39,18 @@ namespace util { } + /////////////////////////////////////////////////////////////////////////// + template + constexpr util::view + align (util::view value, size_t alignment) + { + return { + align (value.begin (), alignment), + value.end () + }; + } + + ///------------------------------------------------------------------------ /// round the pointer upwards to satisfy the provided alignment constexpr inline uintptr_t