MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / MakeProtocolFeatureNames

Function MakeProtocolFeatureNames

src/client/ProtocolFeature.cxx:28–43  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

26 * doesn't support designated initializers for arrays, unlike C99.
27 */
28static constexpr auto
29MakeProtocolFeatureNames() 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
45constinit const std::array<const char *, PF_NUM_OF_ITEM_TYPES> protocol_feature_names = MakeProtocolFeatureNames();
46

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected