27 [[no_unique_address]] putter put;
29 template<
typename cvrT>
void print_(cvrT& x)
31 using T = std::remove_cvref_t<cvrT>;
33 constexpr int max_num_digits =
36 std::is_floating_point_v<T> ? std::numeric_limits<T>::max_digits10
37 + std::numeric_limits<T>::max_exponent10 + 3
40 : (std::numeric_limits<T>::digits10 + std::is_signed_v<T>) ? 1 : 0
43 constexpr int buffer_size = max_num_digits + 16;
45 char buffer[buffer_size];
47 std::string_view string_message;
48 if constexpr (std::is_same_v<T, bool>)
50 string_message = x ?
"true" :
"false";
52 else if constexpr (std::is_arithmetic_v<T>)
54 auto [ptr, ec] = std::to_chars(buffer, buffer + buffer_size, x);
56 if (ec == std::errc()) {
57 string_message = std::string_view(buffer, ptr - buffer);
59 string_message =
"error:\n\
60 bindings/basic_logger/basic_logger.lili:'convert a number'\n\
61 std::to_chars scratch buffer unexpectedly too small!";
64 else if constexpr (
requires {string_message = x;})
66 else if constexpr (
requires {x[0]; x.size();})
69 for (std::size_t i = 1; i < x.size(); ++i) print(
" ", x[i]);
73 else string_message =
"unknown type for basic logger";
75 for (
char c : string_message)
79 template<
typename ... Ts>
void print(Ts... x)
84 template<
typename ... Ts>
void println(Ts... x)