
Artyom wrote:
From: "Stewart, Robert" <Robert.Stewart@sig.com> Artyom wrote:
The static member function
boost::filesystem::path::imbue(std::locale const &)
Is very misleading.
boost::filesystem::path p; p.imbue(some_locale); p="some_file.txt";
Which looks like you change p's locale and not global locale.
I certainly thought so from the various examples like that I've seen on this list.
(I never read the documentation nor noted that imbue() was static, but the code above in no way appears to affect all instances.)
It is just C++, you can call static member function like it is ordinary one.
Thanks for the lesson, but I knew that. I wrote that the code in no way *appears* to affect all instances.
The problem is that imbue in STL and in Boost (regex for example) refers to instance and not to something global.
I acknowledged that very point from your original post.
I'd recommend, provide static member function
boost::filesystem::path::global_locale
"default_locale" would be better since it only affects filesystem::path objects, not everything in the system. That name may not be good enough, though:
p.default_locale(some_locale);
That still seems to affect only the instance, though somewhat less than does "imbue."
See comments above.
I was, again, referring to what that code suggests without the knowledge that the function is static.
With same semantics as imbue and deprecate imbue.
Why not keep imbue() but make it affect individual instances, then add a new function that affects all instances not otherwise affected by a call to imbue()?
I had been thinking about it, the point is that boost::filesystem::path does not need locale instantly it needs it only on the point of conversion between character path and internal path type which is done immediately. So if you need some path specific locale it allows you (if I'm not mistaken about exact syntax) to call
p = fs::path("some_string", std::use_facet<std::codecvt<wchar_t,cha> r,mbstate_t>( some_locale));
Even it is not so nice.
That's pretty ugly.
So I can suggest that it should have a constructors like
path(char const *,std::locale const &) path(wchar_t const *,std::locale const &)
In addition to something like
path(char const *, std::codecvt<wchar_t,char,mbstate_t> const &cvt=codecvt()) path(wchar_t const *, std::codecvt<wchar_t,char,mbstate_t> const &cvt=codecvt())
So the above would look like
p = fs::path("some_string",some_locale);
Much nicer.
Indeed.
Also I would suggest that boost::filesystem could use std::locale's global locale if it is not std::locale::classic() (which can be checked easily) or its own locale, but this is different story.
OK _____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components 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.