File indexing completed on 2025-01-18 09:28:26
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP
0009 #define BOOST_ALIGN_DETAIL_ALIGN_HPP
0010
0011 #include <boost/align/detail/is_alignment.hpp>
0012 #include <boost/assert.hpp>
0013
0014 namespace boost {
0015 namespace alignment {
0016
0017 inline void*
0018 align(std::size_t alignment, std::size_t size, void*& ptr,
0019 std::size_t& space)
0020 {
0021 BOOST_ASSERT(boost::alignment::detail::is_alignment(alignment));
0022 if (size <= space) {
0023 char* p = reinterpret_cast<char*>(~(alignment - 1) &
0024 (reinterpret_cast<std::size_t>(ptr) + alignment - 1));
0025 std::size_t n = p - static_cast<char*>(ptr);
0026 if (n <= space - size) {
0027 ptr = p;
0028 space -= n;
0029 return p;
0030 }
0031 }
0032 return 0;
0033 }
0034
0035 }
0036 }
0037
0038 #endif