src/cpp-common: add bt2_common::align()
[babeltrace.git] / src / cpp-common / align.hpp
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 */
This page took 0.030404 seconds and 4 git commands to generate.