Skip to content

Commit f6fc5e8

Browse files
[libc++][test] Guard non-guaranteed implicit-lifetime-ness cases with _LIBCPP_VERSION (llvm#160627)
And add some guaranteed cases (namely, for `expected`, `optional`, and `variant`) to `is_implicit_lifetime.pass.cpp`. It's somehow unfortunate that `pair` and `tuple` are not guaranteed to propagate triviality of copy/move constructors, and MSVC STL fails to do so due to ABI compatibility. This affects the implicit-lifetime property.
1 parent 0fff270 commit f6fc5e8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
#include <cassert>
1919
#include <cstddef>
20+
#include <expected>
21+
#include <optional>
2022
#include <tuple>
2123
#include <type_traits>
2224
#include <utility>
25+
#include <variant>
2326

2427
#include "test_macros.h"
2528
#include "type_algorithms.h"
@@ -216,8 +219,16 @@ constexpr bool test() {
216219

217220
// C++ standard library types
218221

222+
// These types are guaranteed to be implicit-lifetime.
223+
test_is_implicit_lifetime<std::expected<int, float>>();
224+
test_is_implicit_lifetime<std::optional<float>>();
225+
test_is_implicit_lifetime<std::variant<float, int>>();
226+
227+
#ifdef _LIBCPP_VERSION
228+
// These types should be implicit-lifetime, but they are not guaranteed to be so.
219229
test_is_implicit_lifetime<std::pair<int, float>>();
220230
test_is_implicit_lifetime<std::tuple<int, float>>();
231+
#endif
221232

222233
// Standard C23 types
223234

0 commit comments

Comments
 (0)