When I run the following code it gives me this error:
string val = "847645262";
if (stoull(val) > ULONG_MAX) {
cout << "Bigger";
}
libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: bitset string ctor has invalid argument
And opens up this code in stdexcept from The LLVM Compiler Infrastructure file
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_invalid_argument(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw invalid_argument(__msg); // < - IT STOPS HERE
#else
((void)__msg);
_VSTD::abort();
#endif
}
I also tried changing ULONG_MAX
in UINT64_MAX
but throws the same error, so I manually wrote 18446744073709551615UL
and 0xFFFFFFFFFFFFFFFF
but changing the base doesn't solve the problem.
Therefore I thought the problem was the stoull function but it works perfectly when compared with small integers like 25 or 76.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire