Moved get_init_array() to utility.h
This commit is contained in:
parent
12eec70058
commit
0557bd1651
17
inc/format.h
17
inc/format.h
@ -32,23 +32,6 @@ constexpr int get_output_len() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <fmt_node_t fmt_node>
|
||||
constexpr std::array<char, fmt_node.length> get_init_array() {
|
||||
std::array<char, fmt_node.length> result;
|
||||
|
||||
if constexpr (fmt_node.has_zero_padding) {
|
||||
for (auto& c : result)
|
||||
c = '0';
|
||||
} else {
|
||||
for (auto& c : result)
|
||||
c = ' ';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// TODO: See if this is possible with <charconv>
|
||||
template <fmt_node_t fmt_node, std::integral arg_t>
|
||||
constexpr std::array<char, fmt_node.length> format_arg(arg_t arg) {
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
#define LOGGER_PARSE_TYPES_H
|
||||
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "parse_types.h"
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -16,6 +18,22 @@ constexpr std::size_t const_pow(std::size_t base, std::size_t pow) {
|
||||
}
|
||||
|
||||
|
||||
template <fmt_node_t fmt_node>
|
||||
constexpr std::array<char, fmt_node.length> get_init_array() {
|
||||
std::array<char, fmt_node.length> result;
|
||||
|
||||
if constexpr (fmt_node.has_zero_padding) {
|
||||
for (auto& c : result)
|
||||
c = '0';
|
||||
} else {
|
||||
for (auto& c : result)
|
||||
c = ' ';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user