2013/5/3 Vicente J. Botet Escriba
Le 03/05/13 16:04, TONGARI a écrit :
2013/5/3 Vicente J. Botet Escriba
Le 03/05/13 12:01, Vicente J. Botet Escriba a écrit :
Hi,
on the GSoC discussion about Boost.Chrono/Date proposal we were discussing about date construction. Some of us think that we need to use named types for day, month, year and week so that the date constructors are not ambiguous. Everyone agree with the constant object for month.
date dt(year(2013), may, day(3));
But having to use day(3) or year(2013) seems to wordy.
I was wondering if we can not add some literals for day, year and week so that we can just write
date dt(2013y, may, 3d);
The advantage I see in addition to been less wordy, is that we will have a compile error when the year, day or week is out of range.
Oh I forget the drawbacks. As any other suffix it would need to add a
using statement
using boost::chrono::dates::****literals;
date dt(2013y, may, 3d);
Are any standardized suffixes for day,week and year? Note that these are not the same as days, years, weeks.
Hmm, a user literal must start with '_', isn't it?
date dt(2013_y, may, 3_d);
My personal favor is that just one ctor in YMD order, so I won't need the literals, it's a programming style matter after all...
You can the use
date dt(2013, may, 3, no_check);
IMHO, some static member functions would be simple and elegant (to me) date::ymd, date::mdy, date::dmy What Howard Hinnant had proposed may be a bonus to have date d = year(2013) / month(5) / day(3); But to be frankly with you, I'd like to save some typing. Best,