From ce2006694ed22f5037245c8e391338d034c3c037 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Sun, 21 Nov 2021 18:59:35 +0100 Subject: [PATCH] Made format() constexpr --- inc/format.h | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/format.h b/inc/format.h index 0446e90..814607d 100644 --- a/inc/format.h +++ b/inc/format.h @@ -103,7 +103,7 @@ constexpr char_array_t format_args(char_array_t result, first_arg_t first_arg, template -std::array()> format(args_t... args) { +constexpr std::array()> format(args_t... args) { constexpr auto parse_result = detail::parse_string(); static_assert(parse_result.is_valid, "Syntax error in format string"); diff --git a/src/main.cpp b/src/main.cpp index 5fb0e56..a6c2d26 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ public: 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) std::cout << c;