Boost logo

Boost :

Subject: [boost] [chrono/date] constructor, factories and validation
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-05-05 05:26:12


Hi all,

Two approaches to checking date validation have been proposed

Howard approach:

* date constructors build unchecked dates (provide the same order of parameters that the date factories.
* date factories (expression using operator/()) build checked dates.
* could be completed with make_date that will build checked dates.

Advantages:
* avoids the ugly no_check (that could be replaced by no_throw)

Drawbacks
* The 3 sets of date constructor factories must provide all the same order of parameters.
* Creating a new factory will mean creating a new constructor on each concrete date class.
* The factories must be friend of the concrete dates.

My original approach complemented with make_date factory:

* constructors without no_check build checked dates, and with no_check parameter build well unchecked ones. Provides only decreasing lexicographic order of arguments e.g. date(year,month,day), date(year,month,day,no_check_t).
* make_date provides the usual combinations as provided by factory using operator/() and no_check.
* date factories (expression using operator/()) build checked dates

Advantages:
* There are less date constructors.
* We can add as many factories as we are able to construct with checking or not.

Drawbacks
* the no_throw/no_check/unchecked parameter is ugly and a source of conflict.

Alternative approach (reverse the defaults):
* constructors without check build unchecked dates, and with check parameter build well checked ones. Provides only decreasing lexicographic order of arguments e.g. date(year,month,day), date(year,month,day,check_t).
* make_date provides the usual combinations as provided by factory using operator/() and check.
* a make_checked_date could have also a sens.
* date factories (expression using operator/()) build checked dates

Best,
Vicente


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