2 Copyright 2014-2020 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP
9 #define BOOST_ALIGN_DETAIL_ALIGN_HPP
11 #include <boost/align/detail/is_alignment.hpp>
12 #include <boost/assert.hpp>
18 align(std::size_t alignment, std::size_t size, void*& ptr,
21 BOOST_ASSERT(boost::alignment::detail::is_alignment(alignment));
23 char* p = reinterpret_cast<char*>(~(alignment - 1) &
24 (reinterpret_cast<std::size_t>(ptr) + alignment - 1));
25 std::size_t n = p - static_cast<char*>(ptr);
26 if (n <= space - size) {