diff --git a/sprout/cstdlib/conversion.hpp b/sprout/cstdlib/conversion.hpp index f1c3bc5d..e133d6f4 100644 --- a/sprout/cstdlib/conversion.hpp +++ b/sprout/cstdlib/conversion.hpp @@ -16,5 +16,7 @@ #include #include #include +#include +#include #endif // #ifndef SPROUT_CSTDLIB_CONVERSION_HPP diff --git a/sprout/cstdlib/strtoimax.hpp b/sprout/cstdlib/strtoimax.hpp new file mode 100644 index 00000000..0c0562cc --- /dev/null +++ b/sprout/cstdlib/strtoimax.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_CSTDLIB_STRTOIMAX_HPP +#define SPROUT_CSTDLIB_STRTOIMAX_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // strtol + // + inline SPROUT_CONSTEXPR std::intmax_t strtoimax(char const* str, char** endptr, int base = 10){ + return sprout::str_to_int(str, endptr, base); + } + template + inline SPROUT_CONSTEXPR std::intmax_t strtoimax(Char const* str, Char** endptr, int base = 10){ + return sprout::str_to_int(str, endptr, base); + } + template + inline SPROUT_CONSTEXPR std::intmax_t strtoimax(Char const* str, std::nullptr_t endptr, int base = 10){ + return sprout::str_to_int(str, base); + } + template + inline SPROUT_CONSTEXPR std::intmax_t strtoimax(Char const* str, int base = 10){ + return sprout::str_to_int(str, base); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTDLIB_STRTOIMAX_HPP diff --git a/sprout/cstdlib/strtoumax.hpp b/sprout/cstdlib/strtoumax.hpp new file mode 100644 index 00000000..e200629b --- /dev/null +++ b/sprout/cstdlib/strtoumax.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_CSTDLIB_STRTTOUMAX_HPP +#define SPROUT_CSTDLIB_STRTTOUMAX_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // strtoul + // + inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(char const* str, char** endptr, int base = 10){ + return sprout::str_to_int(str, endptr, base); + } + template + inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(Char const* str, Char** endptr, int base = 10){ + return sprout::str_to_int(str, endptr, base); + } + template + inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(Char const* str, std::nullptr_t endptr, int base = 10){ + return sprout::str_to_int(str, base); + } + template + inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(Char const* str, int base = 10){ + return sprout::str_to_int(str, base); + } +} // namespace sprout + +#endif // #ifndef SPROUT_CSTDLIB_STRTTOUMAX_HPP diff --git a/sprout/string/string_to_int.hpp b/sprout/string/string_to_int.hpp index 05463a65..9d5c58d3 100644 --- a/sprout/string/string_to_int.hpp +++ b/sprout/string/string_to_int.hpp @@ -2,6 +2,7 @@ #define SPROUT_STRING_STRING_TO_INT_HPP #include +#include #include #include #include @@ -111,6 +112,30 @@ namespace sprout { return sprout::string_to_int(str, base); } + // + // stoimax + // + template + inline SPROUT_CONSTEXPR std::intmax_t stoimax(sprout::basic_string const& str, std::size_t* idx, int base = 10) { + return sprout::string_to_int(str, idx, base); + } + template + inline SPROUT_CONSTEXPR std::intmax_t stoimax(sprout::basic_string const& str, int base = 10) { + return sprout::string_to_int(str, base); + } + + // + // stoumax + // + template + inline SPROUT_CONSTEXPR std::uintmax_t stoumax(sprout::basic_string const& str, std::size_t* idx, int base = 10) { + return sprout::string_to_int(str, idx, base); + } + template + inline SPROUT_CONSTEXPR std::uintmax_t stoumax(sprout::basic_string const& str, int base = 10) { + return sprout::string_to_int(str, base); + } + // // from_string //