mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add strtoimax, strtoumax
This commit is contained in:
parent
c532099a35
commit
ece20bf8ef
4 changed files with 87 additions and 0 deletions
|
@ -16,5 +16,7 @@
|
|||
#include <sprout/cstdlib/strtof.hpp>
|
||||
#include <sprout/cstdlib/strtod.hpp>
|
||||
#include <sprout/cstdlib/strtold.hpp>
|
||||
#include <sprout/cstdlib/strtoimax.hpp>
|
||||
#include <sprout/cstdlib/strtoumax.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_CSTDLIB_CONVERSION_HPP
|
||||
|
|
30
sprout/cstdlib/strtoimax.hpp
Normal file
30
sprout/cstdlib/strtoimax.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef SPROUT_CSTDLIB_STRTOIMAX_HPP
|
||||
#define SPROUT_CSTDLIB_STRTOIMAX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/cstdlib/str_to_int.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// strtol
|
||||
//
|
||||
inline SPROUT_CONSTEXPR std::intmax_t strtoimax(char const* str, char** endptr, int base = 10){
|
||||
return sprout::str_to_int<std::intmax_t>(str, endptr, base);
|
||||
}
|
||||
template<typename Char>
|
||||
inline SPROUT_CONSTEXPR std::intmax_t strtoimax(Char const* str, Char** endptr, int base = 10){
|
||||
return sprout::str_to_int<std::intmax_t>(str, endptr, base);
|
||||
}
|
||||
template<typename Char>
|
||||
inline SPROUT_CONSTEXPR std::intmax_t strtoimax(Char const* str, std::nullptr_t endptr, int base = 10){
|
||||
return sprout::str_to_int<std::intmax_t>(str, base);
|
||||
}
|
||||
template<typename Char>
|
||||
inline SPROUT_CONSTEXPR std::intmax_t strtoimax(Char const* str, int base = 10){
|
||||
return sprout::str_to_int<std::intmax_t>(str, base);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CSTDLIB_STRTOIMAX_HPP
|
30
sprout/cstdlib/strtoumax.hpp
Normal file
30
sprout/cstdlib/strtoumax.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef SPROUT_CSTDLIB_STRTTOUMAX_HPP
|
||||
#define SPROUT_CSTDLIB_STRTTOUMAX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/cstdlib/str_to_int.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// strtoul
|
||||
//
|
||||
inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(char const* str, char** endptr, int base = 10){
|
||||
return sprout::str_to_int<std::uintmax_t>(str, endptr, base);
|
||||
}
|
||||
template<typename Char>
|
||||
inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(Char const* str, Char** endptr, int base = 10){
|
||||
return sprout::str_to_int<std::uintmax_t>(str, endptr, base);
|
||||
}
|
||||
template<typename Char>
|
||||
inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(Char const* str, std::nullptr_t endptr, int base = 10){
|
||||
return sprout::str_to_int<std::uintmax_t>(str, base);
|
||||
}
|
||||
template<typename Char>
|
||||
inline SPROUT_CONSTEXPR std::uintmax_t strtoumax(Char const* str, int base = 10){
|
||||
return sprout::str_to_int<std::uintmax_t>(str, base);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CSTDLIB_STRTTOUMAX_HPP
|
|
@ -2,6 +2,7 @@
|
|||
#define SPROUT_STRING_STRING_TO_INT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
|
@ -111,6 +112,30 @@ namespace sprout {
|
|||
return sprout::string_to_int<unsigned long long>(str, base);
|
||||
}
|
||||
|
||||
//
|
||||
// stoimax
|
||||
//
|
||||
template<typename Elem, std::size_t N, typename Traits>
|
||||
inline SPROUT_CONSTEXPR std::intmax_t stoimax(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx, int base = 10) {
|
||||
return sprout::string_to_int<std::intmax_t>(str, idx, base);
|
||||
}
|
||||
template<typename Elem, std::size_t N, typename Traits>
|
||||
inline SPROUT_CONSTEXPR std::intmax_t stoimax(sprout::basic_string<Elem, N, Traits> const& str, int base = 10) {
|
||||
return sprout::string_to_int<std::intmax_t>(str, base);
|
||||
}
|
||||
|
||||
//
|
||||
// stoumax
|
||||
//
|
||||
template<typename Elem, std::size_t N, typename Traits>
|
||||
inline SPROUT_CONSTEXPR std::uintmax_t stoumax(sprout::basic_string<Elem, N, Traits> const& str, std::size_t* idx, int base = 10) {
|
||||
return sprout::string_to_int<std::uintmax_t>(str, idx, base);
|
||||
}
|
||||
template<typename Elem, std::size_t N, typename Traits>
|
||||
inline SPROUT_CONSTEXPR std::uintmax_t stoumax(sprout::basic_string<Elem, N, Traits> const& str, int base = 10) {
|
||||
return sprout::string_to_int<std::uintmax_t>(str, base);
|
||||
}
|
||||
|
||||
//
|
||||
// from_string
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue