Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2005-09-15 08:51:34

Won't respond to all the details in this thread, but a few thoughts. There is
already something in the date-time implementation that does much of this
called constrained_value.

The constraints are specified at build time to reduce the footprint of the
runtime object. Boost date-time uses this to range check things like the
month (1..12). The date-time version is policy based so you can specify how
to handle the out of range condition: exception, log, etc. For example,
here's how the month is setup to throw a bad_month exception:

  struct bad_month : public std::out_of_range {...}

  //! Build a policy class for the greg_month_rep
  typedef CV::simple_exception_policy<unsigned short, 1, 12, bad_month>
  //! A constrained range that implements the gregorian_month rules
  typedef CV::constrained_value<greg_month_policies> greg_month_rep;

  greg_month_rep m(13); //bad_month exception

Christopher Diggins has actually extended this idea and published it in CUJ.
For more you can see his weblog.

We also discussed this on the developer list, so you'll want to search the

Long story short is I'd like to see this as a standalone library -- so I'll
help however I can.


Boost list run by bdawes at, gregod at, cpdaniel at, john at