This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::num_put<char, char*>


Eddie wrote:
Sure, but really you should have a reference for such things: either
the Standard itself (in *.pdf or book form) or a good book, there are
plenty.

Sorry, I guess I should have mentioned that. I was going by "Standard C++ IOStreams and Locales" by Angelika Langer and Klaus Kreft. Page 288 talks of that.

Exactly. You have just just install it in your locale. I'm also going
to make that particular instantiation faster for you ;) (but only for
gcc4.4.0)

Well thank you :) Umm, I know you just told me this isn't a help mailing list. However as I'm sure you know, locales seem to be one of the forgotten realms of C++. The documentation is scarce and those that are familiar with the topic are few and far between. Anyway, how does one "install it in the locale"? Maybe just a point in the right direction of some literature? Heh, thanks.

You install a facet via the locale template ctor, like so:


#include <cassert>
#include <locale>

int main ()
{
    typedef std::num_put<char, char*> NumPut;
    const std::locale x (std::locale::classic (), new NumPut);

    assert (std::has_facet<std::num_put<char> >(x));
    assert (std::has_facet<NumPut>(x));
}

x is a copy of the classic "C" locale with the NumPut facet
added.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]