This is not about me being lazy to write
auto t = time(nullptr);
instead of hypothetical
auto t = time();
I am mostly interested if this is possible, and if it is(AFAIK it is easily implementable since C++ supports function overloading) why it has not been done.
I know obvious answers like: use <chrono>
, nobody wrote proposal, but I wonder if there is a different reason.
My best guess is that nobody wanted to mess with C library functions.
P.S. I understand that some might want to close this question as too vague, but I feel that it is possible to give relatively objective answer to this question.
Function overloading is a feature of Object Oriented programming languages like Java and C++. As we know, C is not an Object Oriented programming language. Therefore, C does not support function overloading.
And C doesn't support Function Overloading.
In which of the following we cannot overload the function? Explanation: While overloading the return function, it will rise a error, So we can't overload the return function.
Function overloading was introduced in C++, so it is not available in C. Polymorphism is an OOP concept, but C is not object-oriented.
The simple answer is that time(time_t)
is “owned” by C rather than by C++: the standard C++ committee doesn’t interfere with the C library unless there are reasons why it is necessary. With C++ you should get a better interface using <chrono>
functions.
Also: I don’t think there was a proposal to overload this function. Without a proposal nothing is going to happen and I doubt anybody sufficiently eager to write such a proposal and get it through the process.
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