Skip to content

Commit 16eee85

Browse files
committed
Add test/variant_default_construct_cx_2. Refs #53.
1 parent e708866 commit 16eee85

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

test/Jamfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,5 @@ for local list-size in $(list-sizes)
157157
{
158158
run variant_index_type.cpp : : : $(index-type-reqs) <define>LIST_SIZE=$(list-size) : variant_index_type_$(list-size) ;
159159
}
160+
161+
compile variant_default_construct_cx_2.cpp ;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2025 Peter Dimov
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/variant2/variant.hpp>
6+
#include <boost/config/pragma_message.hpp>
7+
8+
#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L
9+
10+
BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L")
11+
int main() {}
12+
13+
#else
14+
15+
using namespace boost::variant2;
16+
17+
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
18+
19+
struct X
20+
{
21+
};
22+
23+
struct Y
24+
{
25+
constexpr ~Y() {}
26+
};
27+
28+
struct Z
29+
{
30+
~Z() {}
31+
};
32+
33+
int main()
34+
{
35+
{
36+
constexpr variant<X> v;
37+
STATIC_ASSERT( v.index() == 0 );
38+
}
39+
40+
{
41+
constexpr variant<X, Y> v;
42+
STATIC_ASSERT( v.index() == 0 );
43+
}
44+
45+
{
46+
constexpr variant<X, Y, Z> v;
47+
STATIC_ASSERT( v.index() == 0 );
48+
}
49+
}
50+
51+
#endif

0 commit comments

Comments
 (0)