
Robert Ramey wrote:
Jonathan Turkanis wrote:
Robert Ramey wrote:
add_facet got added to address a short-coming of the older dinkumware library. It would not really be needed except for this.
As to why I did it they way I did - I don't remember. I would guess that I didn't want any more copying than necessary and this implementation worked fine for me.
Sounds reasonable. My guess is that the extra copy will typically be optimized away, but I haven't verified this.
Hmmm - I would have thought the way its done now ther would be no copying necessary at all. Also, I checked the documentation (msvc 7.1) and it didnt' show a copy constructor, I suppose I presumed erroneously that there was one.
Yes, you're right. Dinkumware doesn't document the copy constructor. But it's definitely there (and it's nothrow, too)
For some reason I seem to think that copying a locale wasn't a good idea as I was storing a copy in the archive -
locales are meant to be pretty trivial to copy. The facets should be stored as pointers and are not copied directly. Copying mainly involves updating reference counts. As a result, you should be able to store an archive's locale by value, rather than using a scoped pointer, as it appears you do. (But I am not suggesting you change anything.)
and I sort of remember some issues when archives where deleted re garding the sequence of destruction. Also I found a number of subtle difference in stream implementations that really drove me crazy (of course that's why add_facet exists). On the other hand maybe I just did it that way without thinking. oh well, I guess we'll just have to test it.
I'm sure you'll remember the problems as soon as they happen again ;-) Jonathan