1 // Copyright (c) 2018-2021 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/apolukhin/magic_get/issues/30 7 8 #include <memory> 9 #include <boost/pfr.hpp> 10 #include <boost/core/lightweight_test.hpp> 11 12 struct Message { 13 std::unique_ptr<int> data; 14 }; 15 16 struct Message2 { 17 std::unique_ptr<int> data41 = std::make_unique<int>(41); 18 std::unique_ptr<int> data42 = std::make_unique<int>(42); 19 }; 20 21 // Example from duplicate issue #45 22 struct UniquePtr { 23 std::unique_ptr<int> a; 24 }; 25 static_assert (boost::pfr::tuple_size_v<UniquePtr> == 1, ""); 26 main()27int main() { 28 Message message; 29 auto& ptr = boost::pfr::get<0>(message); 30 BOOST_TEST(ptr == nullptr); 31 32 Message2 message2; 33 auto& ptr2 = boost::pfr::get<1>(message2); 34 BOOST_TEST_EQ(*ptr2, 42); 35 36 return boost::report_errors(); 37 } 38