# cpp-charconv **Repository Path**: shaoguangcn/cpp-charconv ## Basic Information - **Project Name**: cpp-charconv - **Description**: An implementation of STL-charconv for pre-C++17 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-10 - **Last Updated**: 2023-11-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cpp-charconv #### Overview An implementation of STL-charconv for pre-C++17 #### Description ##### Files ```cpp #include "charconv.hpp" ``` ##### Classes - `chars_format` (enum class) : specifies formatting for `to_chars()` and `from_chars()`. - `to_chars_result` (struct) : result type of `to_chars()`. ##### Functions - `from_chars()` : converts a character sequence to an integer or floating-point value. - `to_chars()` : converts an integer or floating-point value to a character sequence. ##### Synopsis ```cpp // floating-point format for primitive numerical conversion enum class chars_format { scientific = /* unspecified */, fixed = /* unspecified */, hex = /* unspecified */, general = fixed | scientific }; // primitive numerical output conversion struct to_chars_result { char* ptr; errc ec; friend bool operator==(const to_chars_result&, const to_chars_result&) = default; }; constexpr to_chars_result to_chars(char* first, char* last, /* integer-type */ value, int base = 10); to_chars_result to_chars(char* first, char* last, bool value, int base = 10) = delete; to_chars_result to_chars(char* first, char* last, /* floating-point-type */ value); to_chars_result to_chars(char* first, char* last, /* floating-point-type */ value, chars_format fmt); to_chars_result to_chars(char* first, char* last, /* floating-point-type */ value, chars_format fmt, int precision); // primitive numerical input conversion struct from_chars_result { const char* ptr; errc ec; friend bool operator==(const from_chars_result&, const from_chars_result&) = default; }; constexpr from_chars_result from_chars(const char* first, const char* last, /* integer-type */& value, int base = 10); from_chars_result from_chars(const char* first, const char* last, /* floating-point-type */& value, chars_format fmt = chars_format::general); ``` #### Compatibility charconv.hpp is cross-platform. Some platform/compiler combinations which have been tested are shown as follows. - Visual C++ 2022 on Windows (64-bit). - GNU C++ 7.5.0 on Ubuntu 18.04. - GNU C++ 11.4.0 on Ubuntu 22.04. - GNU C++ 11.2.0 on Windows (MinGW x86_64-w64-mingw32). #### License [MIT License](LICENSE)