MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / FormatString

Class FormatString

09.13-fixedString3/main.cpp:22–32  ·  view source on GitHub ↗

#A Takes the fixed string as NTTP

Source from the content-addressed store, hash-verified

20
21template<fixed_string Str> // #A Takes the fixed string as NTTP
22struct FormatString {
23 static constexpr auto fmt =
24 Str; // #B Store the string for easy access
25
26 // #C Use ranges to count all the percent signs.
27 static constexpr auto numArgs =
28 std::ranges::count(fmt.data, '%');
29
30 // #D For usability provide a conversion operator
31 operator const auto *() const { return fmt.data; }
32};
33
34template<fixed_string Str>
35constexpr auto operator"" _fs()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected