[libcxx-dev] locale decimal point
Marshall Clow via libcxx-dev
libcxx-dev at lists.llvm.org
Fri Jun 28 07:50:52 PDT 2019
>
> On Fri, Jun 28, 2019 at 7:45 AM Steven Lengieza via libcxx-dev <
> libcxx-dev at lists.llvm.org> wrote:
> Hi,
>
> I am using the following lines of code to get a locale-specific decimal
> point however, it is causing a crash. I am unable to find any libc++
> specific documentation for using std::locale but according to the STL an
> empty string should always be a valid locale. Does this indicate a bug in
> the libc++ implementation or are we doing something wrong?
>
>
> std::locale my_locale("");
> const std::moneypunct<char>& mp =
> std::use_facet<std::moneypunct<char>>(my_locale);
> text += mp.decimal_point();
>
When I paste that into a program, add the correct includes, declare text as
a string, it works fine. (and prints '.')
What version of clang are you using, what system, what C library, etc?
#include <locale>
#include <iostream>
#include <string>
int main () {
std::locale my_locale("");
const std::moneypunct<char>& mp =
std::use_facet<std::moneypunct<char>>(my_locale);
std::string text;
text += mp.decimal_point();
std::cout << "'" << text << "'" << std::endl;
}
-- Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20190628/c4d6373f/attachment.html>
More information about the libcxx-dev
mailing list