What will happen to the std::time(0) function when the number of seconds that have passed since 1970 exceeds the maximum possible number stored in the returned type?
1 answer
Cyclic transfer :) - will go to zero.
But now time_t is 64-bit, as far as I remember ... And for 290 billion years, either C ++, or the Earth, or humanity - but someone will definitely disappear ...
In Visual C ++ 2015
int main(int argc, const char * argv[]) { cout << "sizeof(time_t) = " << sizeof(time_t) << endl; cout << "typeof(time_t) = " << typeid(time_t).name() << endl; } gives
sizeof(time_t) = 8 typeof(time_t) = __int64 - The beauty of
time_tis that when the time comes, the implementation of the compilers will increase its bit depth, as it has already happened before32->64, although there is still a 32-bit implementation margin until 2038 - vp_arth - By the way, a second before it goes to zero, it will return the error flag
(std::time_t)(-1)- vp_arth - @vp_arth how will they increase the bit depth? - user235990
- 3New standard :) - Harry
- oneFrankly, a little different. After 20 years (Tue Jan 19 06:14:07 2038) 32-bit
time_twill become negative (by the way, if someone suddenly doesn’t know,time_tis a signed type), but it will reset (and go to the second round) after 89 years . Similarly, for 64-bit (after 292 billion years it will also become negative, but it will be reset in 584.5 (for reference, the age of the present universe is estimated at 13.81 billion years)) - avp
|
time_ttype has 32 bits) 32-bit systems will be updated ... - avp