WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
AlignOf.h
Go to the documentation of this file.
1//===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the AlignedCharArrayUnion class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef WPIUTIL_WPI_ALIGNOF_H
14#define WPIUTIL_WPI_ALIGNOF_H
15
16#include <algorithm>
17#include <cstddef>
18
19namespace wpi {
20
21/// A suitably aligned and sized character array member which can hold elements
22/// of any type.
23template <typename... Ts> struct AlignedCharArrayUnion {
24 alignas((std::max)({alignof(Ts)...}))
25 std::byte buffer[(std::max)({static_cast<size_t>(1), sizeof(Ts)...})];
26};
27
28} // end namespace wpi
29
30#endif // WPIUTIL_WPI_ALIGNOF_H
Foonathan namespace.
Definition ntcore_cpp.h:26
A suitably aligned and sized character array member which can hold elements of any type.
Definition AlignOf.h:23
std::byte buffer[(std::max)({static_cast< size_t >(1), sizeof(Ts)...})]
Definition AlignOf.h:25