* This function converts the #tag_item_names_init array to an * associative array at compile time. This is a kludge because C++20 * doesn't support designated initializers for arrays, unlike C99. */
| 26 | * doesn't support designated initializers for arrays, unlike C99. |
| 27 | */ |
| 28 | static constexpr auto |
| 29 | MakeProtocolFeatureNames() noexcept |
| 30 | { |
| 31 | std::array<const char *, PF_NUM_OF_ITEM_TYPES> result{}; |
| 32 | |
| 33 | static_assert(std::size(protocol_feature_names_init) == result.size()); |
| 34 | |
| 35 | for (const auto &i : protocol_feature_names_init) { |
| 36 | /* no duplicates allowed */ |
| 37 | assert(result[i.type] == nullptr); |
| 38 | |
| 39 | result[i.type] = i.name; |
| 40 | } |
| 41 | |
| 42 | return result; |
| 43 | } |
| 44 | |
| 45 | constinit const std::array<const char *, PF_NUM_OF_ITEM_TYPES> protocol_feature_names = MakeProtocolFeatureNames(); |
| 46 |