aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclyne <clyne@bitgloo.com>2020-06-29 15:39:24 -0400
committerGitHub <noreply@github.com>2020-06-29 15:39:24 -0400
commit3234772a9009a8f0cfe998b62a72b8b4ba67da5a (patch)
treed64ae685f1941181a0bb896d11917f4cbe043e16
parentefe33d79d5ce0c3afd2aa1cfbebfb862e8a2c5d4 (diff)
make digits inline; simplify digit_count
-rw-r--r--to_string.hpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/to_string.hpp b/to_string.hpp
index 2ea6a60..01a4c4d 100644
--- a/to_string.hpp
+++ b/to_string.hpp
@@ -11,8 +11,7 @@
namespace constexpr_to_string {
-constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-constexpr auto digit_count = sizeof(digits) / sizeof(digits[0]);
+inline constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/**
* @struct to_string_t
@@ -22,7 +21,7 @@ constexpr auto digit_count = sizeof(digits) / sizeof(digits[0]);
*/
template<auto N, int base, typename char_type,
std::enable_if_t<std::is_integral_v<decltype(N)>, int> = 0,
- std::enable_if_t<(base > 1 && base < digit_count), int> = 0>
+ std::enable_if_t<(base > 1 && base < sizeof(digits)), int> = 0>
class to_string_t {
// The lambda calculates what the string length of N will be, so that `buf`
// fits to the number perfectly.