MCPcopy Create free account
hub / github.com/comaps/comaps / ToInteger

Function ToInteger

libs/base/string_utils.hpp:479–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477
478template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
479bool ToInteger(char const * start, T & result, int base = 10)
480{
481 char * stop;
482 errno = 0; // Library functions do not reset it.
483
484 auto const v = IntConverter<T>(start, &stop, base);
485
486 if (errno == EINVAL || errno == ERANGE || *stop != 0 || start == stop || !base::IsCastValid<T>(v))
487 {
488 errno = 0;
489 return false;
490 }
491
492 result = static_cast<T>(v);
493 return true;
494}
495} // namespace internal
496
497[[nodiscard]] inline bool to_int(char const * s, int & i, int base = 10)

Callers 7

to_intFunction · 0.85
to_uintFunction · 0.85
to_uint64Function · 0.85
to_int64Function · 0.85
to_uint32Function · 0.85
to_int32Function · 0.85
to_anyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected