Boost logo

Boost :

Subject: [boost] [chrono/date] conversion between concrete dates
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-05-08 12:08:19


Hi,

as the conversion between concrete dates could be expensive I guess that
these conversion must be explicit.

But this has some consequences when used the implicit conversion was
hidden a not efficient implementation, e.g.

   date ISO_week_start = mon <= jan/day(4)/y;

jan/day(4)/y should be ymd_date as is the efficient representation.

The date generator was declared as

    date operator<=(weekday wd, date x);

but it works efficiently only for days_date. If we provide only the
functions that are efficient we should declare it as

   days_date operator<=(weekday wd, days_date x);

So the preceding expression would need an explicit conversion

   days_date ISO_week_start = mon <= days_date(jan/day(4)/y);

Do we want to go on this direction?

A radical alternative to the explicit construction, if we want to make
evident that the conversion operation could be expensive, is to use a
compute_ factory

   days_date ISO_week_start = mon <= compute_days_date(jan/day(4)/y);

Best,
Vicente

P.S. the generator function is just an example needing explicit conversion.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk