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
19typedef std::allocator<void> A1;
20typedef std::allocator<void const> A2;
21struct A3 : std::allocator<void> { };
22struct A4 : std::allocator<void const> { };
23
24static_assert(std::is_trivially_default_constructible<A1>::value, "");
25static_assert(std::is_trivial<A1>::value, "");
26
27static_assert(std::is_trivially_default_constructible<A2>::value, "");
28static_assert(std::is_trivial<A2>::value, "");
29
30static_assert(std::is_trivially_default_constructible<A3>::value, "");
31static_assert(std::is_trivial<A3>::value, "");
32
33static_assert(std::is_trivially_default_constructible<A4>::value, "");
34static_assert(std::is_trivial<A4>::value, "");
35

source code of libcxx/test/libcxx/memory/allocator_void.trivial.compile.pass.cpp