The copy constructor of time
is marked as explicit
, and when returning a value from a function, a temporary is copy-initialized from that value. Paragraph 8.5/15 of the C++11 Standard specifies:
The initialization that occurs in the form
T x = a;
as well as in argument passing, function return, throwing an exception (15.1), handling an exception (15.3), and aggregate member initialization (8.5.1) is called copy-initialization. [...]
However, constructors marked as explicit
are not considered in the context of a copy-initialization (see 13.3.1.4/1 and 13.3.1.5/1), hence the error.