aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclyne <clyne@bitgloo.com>2020-06-26 11:13:25 -0400
committerGitHub <noreply@github.com>2020-06-26 11:13:25 -0400
commit0f38f29202f4b7184d35cd0145c0172be4ff126d (patch)
tree6c697c5c1195221a2cfca58bb08a5cdc43a26582
parenta436ba686746c672d7dadef03057efefbcdb0e50 (diff)
Update README.md
-rw-r--r--README.md25
1 files changed, 24 insertions, 1 deletions
diff --git a/README.md b/README.md
index 1bbc479..9c1ebcf 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,25 @@
# constexpr-to-string
-C++17 code to convert integers to strings at compile-time
+
+**Features:**
+
+* Convert any integral type to a string at compile-time
+* String can be in binary, hexadecimal, or any base in-between
+* No external dependencies, only includes `type_traits` for type-checking
+* Works best in C++20 GCC or C++17/20 Clang
+
+**How to use:**
+
+This single header file provides a `to_string` utility, which may be used as below:
+
+```cpp
+const char *number = to_string<2147483648999954564, 16>; // produces "1DCD65003B9A1884"
+puts(number);
+puts(to_string<-42>); // produces "-42"
+puts(to_string<30, 2>); // produces "11110"
+```
+
+With `to_string`, all that will be found in program disassembly are the resulting string literals, as if you wrote the strings yourself.
+
+**Known issues:**
+
+* With C++17 GCC, `to_string` must be used to initialize variables; otherwise, the integer-string conversion is done at run-time.