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#include <__type_traits/datasizeof.h>
10#include <cstdint>
11
12static_assert(std::__libcpp_datasizeof<std::int8_t>::value == 1, "");
13static_assert(std::__libcpp_datasizeof<std::int16_t>::value == 2, "");
14static_assert(std::__libcpp_datasizeof<std::int32_t>::value == 4, "");
15static_assert(std::__libcpp_datasizeof<std::int64_t>::value == 8, "");
16
17struct OneBytePadding {
18 OneBytePadding() {}
19
20 std::int16_t a;
21 std::int8_t b;
22};
23
24#if defined(_WIN32) && !defined(__MINGW32__)
25static_assert(std::__libcpp_datasizeof<OneBytePadding>::value == 4, "");
26#else
27static_assert(std::__libcpp_datasizeof<OneBytePadding>::value == 3, "");
28#endif
29
30struct InBetweenPadding {
31 InBetweenPadding() {}
32
33 std::int32_t a;
34 std::int8_t b;
35 std::int16_t c;
36};
37
38static_assert(std::__libcpp_datasizeof<InBetweenPadding>::value == 8, "");
39

source code of libcxx/test/libcxx/type_traits/datasizeof.compile.pass.cpp