I want to write a very portable code, and I need to call std::chrono::system_clock::now() in the initialization. Can this function throw an exception ?
In c++11 standard, there is no mention of that issue. (At least, I didn't found one)
In Visual Studio, the sourcecode is as follow :
static time_point now() _NOEXCEPT
{ // get current time
return (time_point(duration(_Xtime_get_ticks())));
}
With the _NOEXCEPT keyword, the answer in visual studio is pretty obvious. But what about the general case ?
From §20.11.7.1
class system_clock {
public:
...
static time_point now() noexcept;
...
};
So the standard states it cannot throw an exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With