Commit | Line | Data |
---|---|---|
f38a365f PP |
1 | /* |
2 | * Copyright (c) 2022 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: MIT | |
5 | */ | |
6 | ||
7 | #ifndef BABELTRACE_CPP_COMMON_ALIGN_HPP | |
8 | #define BABELTRACE_CPP_COMMON_ALIGN_HPP | |
9 | ||
10 | #include <type_traits> | |
11 | ||
12 | #include "common/align.h" | |
13 | ||
14 | namespace bt2_common { | |
15 | ||
16 | template <typename ValT, typename AlignT> | |
17 | ValT align(const ValT val, const AlignT align) noexcept | |
18 | { | |
19 | static_assert(std::is_unsigned<ValT>::value, "`ValT` is unsigned."); | |
20 | return BT_ALIGN(val, static_cast<ValT>(align)); | |
21 | } | |
22 | ||
23 | } /* namespace bt2_common */ | |
24 | ||
25 | #endif /* BABELTRACE_CPP_COMMON_ALIGN_HPP */ |