| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include <QtCore/qfunctionaltools_impl.h> |
| 5 | |
| 6 | // Remove this file once we have tests that implicitly test all aspects of |
| 7 | // CompactStorage |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | namespace QtPrivate { |
| 12 | |
| 13 | #define FOR_EACH_CVREF(op) \ |
| 14 | op(&) \ |
| 15 | op(const &) \ |
| 16 | op(&&) \ |
| 17 | op(const &&) \ |
| 18 | /* end */ |
| 19 | |
| 20 | namespace _testing { |
| 21 | struct empty {}; |
| 22 | struct final final {}; |
| 23 | static_assert(std::is_same_v<CompactStorage<empty>, |
| 24 | detail::StorageEmptyBaseClassOptimization<empty>>); |
| 25 | static_assert(std::is_same_v<CompactStorage<final>, |
| 26 | detail::StorageByValue<final>>); |
| 27 | static_assert(std::is_same_v<CompactStorage<int>, |
| 28 | detail::StorageByValue<int>>); |
| 29 | #define CHECK1(Obj, cvref) \ |
| 30 | static_assert(std::is_same_v<decltype(std::declval<CompactStorage< Obj > cvref>().object()), \ |
| 31 | Obj cvref>); |
| 32 | #define CHECK(cvref) \ |
| 33 | CHECK1(empty, cvref) \ |
| 34 | CHECK1(final, cvref) \ |
| 35 | CHECK1(int, cvref) \ |
| 36 | /* end */ |
| 37 | |
| 38 | FOR_EACH_CVREF(CHECK) |
| 39 | #undef CHECK |
| 40 | #undef CHECK1 |
| 41 | } // namespace _testing |
| 42 | |
| 43 | } // namespace QtPrivate |
| 44 | |
| 45 | #undef FOR_EACH_CVREF |
| 46 | |
| 47 | QT_END_NAMESPACE |
| 48 |
