1// Copyright (c) 2018-2024 Antony Polukhin
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#include <boost/pfr/tuple_size.hpp>
7
8#include <boost/core/lightweight_test.hpp>
9
10struct X {
11 X() = default;
12 X(X&&) = delete;
13 X(const X&) = delete;
14
15 X& operator=(X&&) = delete;
16 X& operator=(const X&) = delete;
17};
18struct S { X x0; X x1; int x2; X x3; };
19
20int main() {
21
22#if BOOST_PFR_HAS_GUARANTEED_COPY_ELISION
23
24// MSVC-14.3 fails this test
25#if !defined(_MSC_VER) || _MSC_VER < 1930 || _MSC_VER > 1939
26 static_assert(boost::pfr::tuple_size_v<S> == 4, "");
27
28 struct S5_0 { int x0; int x1; int x2; int x3; X x4; };
29 static_assert(boost::pfr::tuple_size_v<S5_0> == 5, "");
30
31 struct S5_1 { X x0; int x1; int x2; int x3; int x4; };
32 static_assert(boost::pfr::tuple_size_v<S5_1> == 5, "");
33
34 struct S5_2 { int x0; int x1; X x2; int x3; int x4; };
35 static_assert(boost::pfr::tuple_size_v<S5_2> == 5, "");
36
37 struct S5_3 { int x0; int x1; X x2; int x3; X x4; };
38 static_assert(boost::pfr::tuple_size_v<S5_3> == 5, "");
39
40 struct S5_4 { X x0; X x1; X x2; X x3; X x4; };
41 static_assert(boost::pfr::tuple_size_v<S5_4> == 5, "");
42
43 struct S6 { X x0; X x1; X x2; X x3; X x4; X x5;};
44 static_assert(boost::pfr::tuple_size_v<S6> == 6, "");
45#endif
46
47#endif // #if BOOST_PFR_HAS_GUARANTEED_COPY_ELISION
48
49 return boost::report_errors();
50}
51
52

source code of boost/libs/pfr/test/core/run/non_movable.cpp