aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorclyne <clyne@bitgloo.com>2020-06-29 15:17:38 -0400
committerGitHub <noreply@github.com>2020-06-29 15:17:38 -0400
commit6710f1e69901b782617671cc36c2bf9c81e3be53 (patch)
tree3cfc78c8735140f7aa2b1afe8567e47312a0085c /README.md
parent703b3fb5b0d4db4b590874a64fd97c828aa85190 (diff)
parent2717bb70eadf98411dee246de389668ea7033499 (diff)
Merge pull request #3 from SecMeant/digits_array
Removing magic constant from template param check
Diffstat (limited to 'README.md')
-rw-r--r--README.md4
1 files changed, 3 insertions, 1 deletions
diff --git a/README.md b/README.md
index 75ad580..050db38 100644
--- a/README.md
+++ b/README.md
@@ -56,11 +56,13 @@ The integer/string conversion is done using a simple method I learned over the y
(*Note: The below examples of code are not up-to-date, though they still give a general idea of how `to_string` works.*)
```cpp
+constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
constexpr to_string_t() {
auto ptr = buf + sizeof(buf) / sizeof(buf[0]);
*--ptr = '\0';
for (auto n = N < 0 ? -N : N; n; n /= base)
- *--ptr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[n % base];
+ *--ptr = digits[n % base];
if (N < 0)
*--ptr = '-';
}