incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Teleman <stefan.tele...@gmail.com>
Subject Re: STDCXX-1056 [was: Re: STDCXX forks]
Date Sat, 15 Sep 2012 05:47:24 GMT
On Thu, Sep 13, 2012 at 1:40 AM, Stefan Teleman
<stefan.teleman@gmail.com> wrote:

> The performance of 22.locale.numpunct.mt is also much better with your
> _numpunct.h patch:
>
> real 668.93
> user 804.00
> sys 34.24

Unfortunately, the resulting facet is non-conformant. For this simple test case:

#include <locale>

#include <cstdio>
#include <cstdlib>

template<class _CharT>
class my_numpunct : public std::numpunct<_CharT>
{
public:
    typedef _CharT char_type;

    explicit my_numpunct<_CharT>() : std::numpunct<_CharT>() { }
    ~my_numpunct ()  { }

protected:
    virtual char_type do_decimal_point () const {
        std::printf("Hello, my name is my_numpunct::do_decimal_point.\n");
        return std::numpunct<_CharT>::do_decimal_point ();
    }

    virtual std::string do_grouping () const {
        std::printf("Hello, my name is my_numpunct::do_grouping.\n");
        return std::numpunct<_CharT>::do_grouping ();
    }
};

int
main(int argc, char* argv[])
{

    if (argc != 2) {
        std::fprintf(stderr, "Usage: %s <locale-name>\n", argv[0]);
        return -1;
    }

    std::locale l(argv[1]);
    std::locale loc(l, new my_numpunct<char> ());

    my_numpunct<char> const& fac =
        std::use_facet<my_numpunct<char> > (loc);

    char dp = fac.decimal_point();
    char ts = fac.thousands_sep();
    std::string gr = fac.grouping();
    std::string tn = fac.truename();

    std::fprintf(stderr, "dp = '%c' ts = '%c' gr = \"%s\" tn = \"%s\"\n",
                    dp, ts, gr.c_str(), tn.c_str());

    return 0;
}

I expect the following output:

[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/stdcxx-4.2.1/tests/localization][09/15/2012
1:44:35][1134]>> ./22.locale.numpunct.stefan-1-gcc en_US.utf-8
Hello, my name is my_numpunct::do_decimal_point.
Hello, my name is my_numpunct::do_grouping.
dp = '.' ts = ',' gr = "" tn = "true"

I get this instead:

[steleman@darthvader][/src/steleman/programming/stdcxx-intel/stdcxx-4.2.1-thread-safe/build/tests][09/14/2012
22:31:22][1449]>> ./22.locale.numpunct.stefan-1 en_US.utf-8
dp = '.' ts = ',' gr = "" tn = "true"

--Stefan

-- 
Stefan Teleman
KDE e.V.
stefan.teleman@gmail.com

Mime
View raw message