Boost logo

Boost :

From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2006-02-25 17:50:04


Hi.
I've used the date_time I/O using facets and found it too complicated.
The thing that bothers me is that I need to use a facet to specify the
format string (e.g "HH:MM:SS"). This is burdensome. IMO, using facets is
fine for defining things which are really locale-related (and are mostly
constant during the process lifetime) such as the month names in the
local language. The format is not such a property and can often change
throughout the application, and as such is much better handled using an
I/O manipulator:

     cout << time_format("HH:MM:SS") << my_ptime << endl;

or if this is impossible, then

     cout << time_io(my_ptime, "HH:MM:SS") << endl;

which surely is possible.

I think of specifying the format string as similar to specifying the
printing precision of a float, or specifying that an integer should be
printed as hex. These are provided as manipulators without the
complexity of facets (which most users, including me, know very little
about).

BTW, this is not my original idea. I saw it in a post (don't remember by
whom) in this mailing list a few months ago.

Thanks,
Yuval


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