| 9269 | using unique_tag = detail::inheritance_unique_cast_function; |
| 9270 | |
| 9271 | inline void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space, std::size_t& required_space) { |
| 9272 | // this handels arbitrary alignments... |
| 9273 | // make this into a power-of-2-only? |
| 9274 | // actually can't: this is a C++14-compatible framework, |
| 9275 | // power of 2 alignment is C++17 |
| 9276 | std::uintptr_t initial = reinterpret_cast<std::uintptr_t>(ptr); |
| 9277 | std::uintptr_t offby = static_cast<std::uintptr_t>(initial % alignment); |
| 9278 | std::uintptr_t padding = (alignment - offby) % alignment; |
| 9279 | required_space += size + padding; |
| 9280 | if (space < required_space) { |
| 9281 | return nullptr; |
| 9282 | } |
| 9283 | ptr = static_cast<void*>(static_cast<char*>(ptr) + padding); |
| 9284 | space -= padding; |
| 9285 | return ptr; |
| 9286 | } |
| 9287 | |
| 9288 | inline void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space) { |
| 9289 | std::size_t required_space = 0; |
no outgoing calls
no test coverage detected