1 | //===----------------------------------------------------------------------===// |
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 | // Make sure that std::allocator<void> is trivial. This was the case before C++20 |
10 | // with the std::allocator<void> explicit specialization, and this test makes sure |
11 | // that we maintain that property across all standards. |
12 | // |
13 | // This is important since triviality has implications on how the type is passed |
14 | // as a function argument in the ABI. |
15 | |
16 | #include <memory> |
17 | #include <type_traits> |
18 | |
19 | typedef std::allocator<void> A1; |
20 | typedef std::allocator<void const> A2; |
21 | struct A3 : std::allocator<void> { }; |
22 | struct A4 : std::allocator<void const> { }; |
23 | |
24 | static_assert(std::is_trivially_default_constructible<A1>::value, "" ); |
25 | static_assert(std::is_trivial<A1>::value, "" ); |
26 | |
27 | static_assert(std::is_trivially_default_constructible<A2>::value, "" ); |
28 | static_assert(std::is_trivial<A2>::value, "" ); |
29 | |
30 | static_assert(std::is_trivially_default_constructible<A3>::value, "" ); |
31 | static_assert(std::is_trivial<A3>::value, "" ); |
32 | |
33 | static_assert(std::is_trivially_default_constructible<A4>::value, "" ); |
34 | static_assert(std::is_trivial<A4>::value, "" ); |
35 | |