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// Test case for https://github.com/boostorg/pfr/issues/33
7
8#include <iostream>
9#include <memory>
10#include <vector>
11#include <boost/pfr.hpp>
12#include <boost/core/lightweight_test.hpp>
13
14struct TestStruct {
15 std::vector<std::unique_ptr<int>> vec;
16};
17
18
19int main() {
20 TestStruct temp;
21 temp.vec.emplace_back();
22
23// FIXME: https://github.com/boostorg/pfr/issues/131
24#if defined(__clang__) && __cplusplus >= 202002L
25
26# if BOOST_PFR_USE_LOOPHOLE == 0 && BOOST_PFR_USE_CPP17 == 0
27# error This test should fail on classic engine
28#endif
29
30#else
31 boost::pfr::for_each_field(value&: temp, func: [](const auto& value) {
32 BOOST_TEST_EQ(value.size(), 1);
33 });
34#endif
35
36 return boost::report_errors();
37}
38

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