# Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov. # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # Initial implementation by Bela Schaum, https://github.com/schaumb # The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669 # ############################################################################################################################ import sys import string import random # a bigger value might lead to compiler out of heap space error on MSVC STRUCT_COUNT = 50 MAX_FIELD_COUNT = 50 MAIN_TEMPLATE = """// Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov, Antony Polukhin. // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // Generated by misc/generate_fields_names_big.cpp.py #include #include #include namespace testing { template auto make_stdarray(const Types&... t) { return std::array, sizeof...(Types)>{t...}; } %STRUCTS_LIST% %TEST_GET_NAME_DEFINITIONS_LIST% %TEST_GET_NAMES_AS_ARRAY_DEFINITIONS_LIST% } // namespace testing int main() { %TEST_GET_NAME_CALLS_LIST% %TEST_GET_NAMES_AS_ARRAY_CALLS_LIST% return boost::report_errors(); } """ STRUCT_TEMPLATE = """struct Aggregate%STRUCT_ID% { %FIELD_DEFINITIONS_LIST% }; """ STRUCT_FIELD_DEFINITION_TEMPLATE = """int %FIELD_NAME%; """ TEST_GET_NAME_TEMPLATE = """void test_get_name_%TEST_ID%() { %CHECKERS_LIST% } """ TEST_GET_NAME_CHECKER_TEMPLATE = """BOOST_TEST_EQ( ((boost::pfr::get_name<%FIELD_ID%, Aggregate%STRUCT_ID%>())), "%FIELD_NAME%"); """ TEST_GET_NAMES_AS_ARRAY_TEMPLATE = """void test_names_as_array_%TEST_ID%() { const auto expected = make_stdarray( %FIELD_NAMES_LIST% ); const auto value = boost::pfr::names_as_array(); BOOST_TEST_EQ(expected.size(), value.size()); for (std::size_t i=0;i