forked from OSchip/llvm-project
Document that AlignedCharArrayUnion exists to work around an MSVC bug
Differential Revision: https://reviews.llvm.org/D93355
This commit is contained in:
parent
f43e67cc6c
commit
b0b5d38963
|
@ -20,9 +20,10 @@ namespace llvm {
|
||||||
/// A suitably aligned and sized character array member which can hold elements
|
/// A suitably aligned and sized character array member which can hold elements
|
||||||
/// of any type.
|
/// of any type.
|
||||||
///
|
///
|
||||||
/// These types may be arrays, structs, or any other types. This exposes a
|
/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot
|
||||||
/// `buffer` member which can be used as suitable storage for a placement new of
|
/// use it due to a bug in the MSVC x86 compiler:
|
||||||
/// any of these types.
|
/// https://github.com/microsoft/STL/issues/1533
|
||||||
|
/// Using `alignas` here works around the bug.
|
||||||
template <typename T, typename... Ts> struct AlignedCharArrayUnion {
|
template <typename T, typename... Ts> struct AlignedCharArrayUnion {
|
||||||
using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
|
using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
|
||||||
alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
|
alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
|
||||||
|
|
Loading…
Reference in New Issue