Circus 0.0.1-alpha
C++ Serialization Framework
Loading...
Searching...
No Matches
to_chars.hpp
Go to the documentation of this file.
1
5
6#pragma once
7#include <iostream>
8
9namespace circus::utils {
10
11namespace detail {
12
18template <unsigned... digits>
19struct to_chars {
21 static const char value[];
22};
23
27template <unsigned... digits>
28constexpr char to_chars<digits...>::value[] = {('0' + digits)..., 0};
29
36template <unsigned rem, unsigned... digits>
37struct explode : explode<rem / 10, rem % 10, digits...> {};
38
45template <unsigned... digits>
46struct explode<0, digits...> : to_chars<digits...> {};
47
48} // namespace detail
49
57template <unsigned num>
59
67constexpr bool strings_equal(char const* a, char const* b) {
68 return std::string_view(a) == b;
69}
70
71} // namespace circus::utils
Compile-time recursion to split an unsigned integer into digits.
Definition to_chars.hpp:37
Helper template that stores a compile-time char array of digits.
Definition to_chars.hpp:19
static const char value[]
Null-terminated character array representing the number.
Definition to_chars.hpp:21
Converts a compile-time unsigned integer to a string literal.
Definition to_chars.hpp:58
constexpr bool strings_equal(char const *a, char const *b)
Compile-time string equality check.
Definition to_chars.hpp:67
constexpr char to_chars< digits... >::value[]
Definition of the static char array containing digits plus terminating null.
Definition to_chars.hpp:28