tomaszkam / date

A date and time library based on the C++11/14/17 <chrono> header
Other
0 stars 0 forks source link

[EXT] Make clock's default constructor explicit #24

Closed tomaszkam closed 5 years ago

tomaszkam commented 5 years ago

Original comment:

Give clocks an explicit clock() = default;

HowardHinnant commented 5 years ago

I recommend closing this one.

I wrote it to prevent code like this:

void test(system_clock);
...
test({});

This comes from our experience that tag types should have an explicit default constructor, for example defer_lock_t: http://eel.is/c++draft/mutex.syn

However we've lived with clocks the way they are since C++11, and I haven't heard of any complaints from the wild, probably because people aren't passing clock objects around. This can be changed in C++23 should the need arise.

tomaszkam commented 5 years ago

Agreed. I think that would be also LEWG territory, to see if the clock should be treated as tag types.