Made format() constexpr
This commit is contained in:
parent
53091a30cd
commit
ce2006694e
@ -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");
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user