user defined facets in date_time library

While trying to make date_time tests compilable on tru64cxx65, I have come accross an issue with user defined facets (namely date_names_put and all_date_names_put) that leaves me scratching my head. Is a user defined facet required to be default constructible? Or does it need a constructor of the form "foo(size_t refs = 0) : locale::facet(refs) {}"? [lib.facets.examples] doesn't say so but most examples I could find either have a default constructor or a constructor taking a reference count. Markus

On Mon, 30 Aug 2004 13:25:51 +0200, Markus Schöpflin wrote
While trying to make date_time tests compilable on tru64cxx65, I have come accross an issue with user defined facets (namely date_names_put and all_date_names_put) that leaves me scratching my head.
Is a user defined facet required to be default constructible?
No, in fact I don't think any of the examples are default constructable.
Or does it need a constructor of the form "foo(size_t refs = 0) : locale::facet(refs) {}"?
There should be no requirements ont the constructor. date_names_put is the base interface while all_date_names_put is an implementation that allows the passing of a bunch of char arrays to get the desired date output.
[lib.facets.examples] doesn't say so but most examples I could find either have a default constructor or a constructor taking a reference count.
I'm not sure where you are seeing these examples, but if you looking in libs/date_time/test/gregroian/testfacet.cpp I don't think you will find any default constructors. Maybe you can send me some of the errors you are getting -- onlist or off -- your choice? Jeff

Jeff Garland wrote:
On Mon, 30 Aug 2004 13:25:51 +0200, Markus Schöpflin wrote
...
[lib.facets.examples] doesn't say so but most examples I could find either have a default constructor or a constructor taking a reference count.
I'm not sure where you are seeing these examples, but if you looking in libs/date_time/test/gregroian/testfacet.cpp I don't think you will find any default constructors.
Maybe you can send me some of the errors you are getting -- onlist or off -- your choice?
I'll be trying to make myself more clear this time. Currently, not all date_time tests compile with tru64cxx65. This is because of a problem in the RW std library used on that platform. I now have received a patch from HP which should fix the problem. But the patch now requires a user defined facet to be default constructible, which the date_time facets are not. Therefore, the tests still won't compile. I now was wondering what the standard actually requires of a user defined facet (IOW if the date_time facets are legal) and all I could find was [lib.facets.examples] which isn't really much. Therefore I looked around a little more for other examples of user defined facets (besides date_time) and most of the examples I found were either default constructible or had a constructor which takes a refs argument. Therefore I decided to ask what the standard actually requires of a user defined facet. Currently I'm thinking that both facets below are legal according to the C++ standard and therefore that the error I'm still getting on my platform is a problem of the std library and not of date_time. ---%<--- #include <locale> struct foo : std::locale::facet { static std::locale::id id; }; struct bar : std::locale::facet { static std::locale::id id; bar(int) { } }; std::locale::id foo::id; std::locale::id bar::id; int main() { std::use_facet<foo>(std::locale()); std::use_facet<bar>(std::locale()); return 0; } --->%--- Sorry for any confusion I might have caused... Markus

On Tue, 31 Aug 2004 10:59:47 +0200, Markus Schöpflin wrote
I'll be trying to make myself more clear this time.
Currently, not all date_time tests compile with tru64cxx65. This is because of a problem in the RW std library used on that platform. I now have received a patch from HP which should fix the problem. But the patch now requires a user defined facet to be default constructible, which the date_time facets are not. Therefore, the tests still won't compile.
...snip details...
Sorry for any confusion I might have caused...
No problem, thanks for the clarifications. And nice work on getting the vendor to fix the library. Between lack of support for wchar, library, and compiler issues, writing 'standard' I/O for date_time has been a big pain. The vast majority of the macro hacks and test failures have to do with I/O support... Jeff
participants (2)
-
Jeff Garland
-
Markus Schöpflin