Made format() constexpr

This commit is contained in:
Andreas Tsouchlos 2021-11-21 18:59:35 +01:00
parent 53091a30cd
commit ce2006694e
2 changed files with 2 additions and 2 deletions

View File

@ -103,7 +103,7 @@ constexpr char_array_t format_args(char_array_t result, first_arg_t first_arg,
template <detail::ConstString s, typename... args_t> template <detail::ConstString s, typename... args_t>
std::array<char, detail::get_output_len<s>()> format(args_t... args) { constexpr std::array<char, detail::get_output_len<s>()> format(args_t... args) {
constexpr auto parse_result = detail::parse_string<s>(); constexpr auto parse_result = detail::parse_string<s>();
static_assert(parse_result.is_valid, "Syntax error in format string"); static_assert(parse_result.is_valid, "Syntax error in format string");

View File

@ -12,7 +12,7 @@ public:
int main() { int main() {
const auto formatted = format<"Test: {:3.8f} {:5.5} {:05.2}">(3.4, "abc", 1234); constexpr auto formatted = format<"Test: {:3.8f} {:5.5} {:05.2}">(3.4, "abc", 1234);
for (const auto& c : formatted) for (const auto& c : formatted)
std::cout << c; std::cout << c;