1// Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov.
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
7// Initial implementation by Bela Schaum, https://github.com/schaumb
8// The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669
9//
10
11#include <iostream>
12
13// This cpp file:
14// * tests BOOST_PFR_CORE_NAME_PARSING macro
15// * outputs full name of the function so that PFRs extraction of field name could be adjust to new compiler without requesting regression tester's help
16#ifndef BOOST_PFR_CORE_NAME_PARSING
17#define BOOST_PFR_CORE_NAME_PARSING (0,0,"")
18#endif
19
20#include <boost/pfr/core_name.hpp>
21
22namespace user_defined_namespace {
23 struct user_defined_class { int user_defined_field; };
24}
25
26using namespace boost::pfr;
27
28// Cloned from core_name20_static.hpp but removed the sanity check
29template <class T, std::size_t I>
30inline constexpr auto no_check_stored_name_of_field = detail::name_of_field_impl<T,
31 detail::make_clang_wrapper(std::addressof(detail::sequence_tuple::get<I>(
32 detail::tie_as_tuple(detail::fake_object<T>())
33 )))
34>();
35
36int main()
37{
38 std::cout << "user_defined_namespace::user_defined_class::user_defined_field: "
39 << no_check_stored_name_of_field<user_defined_namespace::user_defined_class, 0>.data() << '\n';
40
41
42 return 0;
43}
44
45

source code of boost/libs/pfr/test/core_name/print_name.cpp