[filesystem][v3] Class path codecvt argument now available for appropriate functions

The initial V3 implementation, like V2, could alter the codecvt facet used for conversion via a static imbue() function. This has a number of problems, including: * It is, in effect, a global variable, and thus "considered harmful" as being prone to abuse. * It is subject to data races in multi-threaded environments. * It can be hard to use. * It can be hard to explain. As of revision 63283 this morning, V3 class path in trunk now has an additional "const codecvt&" for all functions where conversion may be required. So you can now write: utf8_codecvt_facet utf8; // UTF-8 facet from boost or other sources path p(some_string, utf8); // some_string will be treated as UTF-8 encoded ... operations on p That's great, but where does that leave path::imbue? I think it should be deprecated. What do others think? --Beman

Beman Dawes wrote:
The initial V3 implementation, like V2, could alter the codecvt facet used for conversion via a static imbue() function. This has a number of problems, including:
* It is, in effect, a global variable, and thus "considered harmful" as being prone to abuse.
Many things in the standard library can be abused. That doesn't mean it should be easy or the only way to do a thing, but there is precedent for the inclusion of abuse prone constructs.
* It is subject to data races in multi-threaded environments.
If an application imbues a codecvt facet in main() before creating threads, is that still an issue? IOW, can it not be used safely?
* It can be hard to use.
* It can be hard to explain.
No comment.
As of revision 63283 this morning, V3 class path in trunk now has an additional "const codecvt&" for all functions where conversion may be required.[snip]
That's great, but where does that leave path::imbue? I think it should be deprecated. What do others think?
I'd be inclined to leave it for those that always want a single codecvt facet, but I have no horse in this race. _____ Rob Stewart robert.stewart@sig.com Software Engineer, Core Software using std::disclaimer; Susquehanna International Group, LLP http://www.sig.com IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

On Thu, Jun 24, 2010 at 12:31 PM, Stewart, Robert <Robert.Stewart@sig.com> wrote:
Beman Dawes wrote:
The initial V3 implementation, like V2, could alter the codecvt facet used for conversion via a static imbue() function. This has a number of problems, including:
* It is, in effect, a global variable, and thus "considered harmful" as being prone to abuse.
Many things in the standard library can be abused. That doesn't mean it should be easy or the only way to do a thing, but there is precedent for the inclusion of abuse prone constructs.
* It is subject to data races in multi-threaded environments.
If an application imbues a codecvt facet in main() before creating threads, is that still an issue? IOW, can it not be used safely?
AFAIK, there is no problem if the facet is imbued before creating threads.
* It can be hard to use.
* It can be hard to explain.
No comment.
As of revision 63283 this morning, V3 class path in trunk now has an additional "const codecvt&" for all functions where conversion may be required.[snip]
That's great, but where does that leave path::imbue? I think it should be deprecated. What do others think?
I'd be inclined to leave it for those that always want a single codecvt facet, but I have no horse in this race.
It is still in for the moment. I guess I don't feel strongly about it. Thanks, --Beman

On Thu, 24 Jun 2010 16:22:26 -0400, Beman Dawes wrote:
That's great, but where does that leave path::imbue? I think it should be deprecated. What do others think?
I'd be inclined to leave it for those that always want a single codecvt facet, but I have no horse in this race.
It is still in for the moment. I guess I don't feel strongly about it.
I'd say leave it. Just because I want to use specific path encodings here and there doesn't mean I don't want a custom default. If you remove the global imbue, my only alternative in that situation would be to imbue every path individually. Alex -- Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
participants (3)
-
Alexander Lamaison
-
Beman Dawes
-
Stewart, Robert