On May 4, 2013, at 7:57 AM, Rob Stewart
My still-preferred spelling for the factory functions (yes, more than 1) is:
date d = year(2013) / month(5) / day(3); date d = year(2013) / month(5) / 3; date d = month(5) / day(3) / year(2013); date d = month(5) / day(3) / 2013; date d = day(3) / month(5) / year(2013); date d = day(3) / month(5) / 2013;
To implement those, you must either introduce intermediate types, like year_and_month, with and overloaded operator /, or you need expression templates to shuffle the argument order before forwarding to a single, checked, date constructor.
Correct, I was strongly leaning towards the former: intermediate types like year_and_month. And an open question is whether or not year_and_month would be a useful type to the client outside of this role. E.g. would it be useful to perform month arithmetic on a year_month object? Would it be helpful to get the number of days in a month out of a year_month object? Or is year_month simply an implementation detail that the client never sees? Personally I am still exploring these questions. Howard