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: Rethinking... (Re: RFC: fp printing speedup...)


Martin Sebor wrote:

CharT widen(char) {
 if (!cache) {
    cache = getcache();
    do_widen(cache.CharTarray, cache.chararry);
 }
 return cache.CharTarray[char];
}

Well, wait. What if ctype.widen looked like:

Whoops, I just now noticed that you're calling the array form from the
non-array form. That's definitely not what the standard now requires.
Hmmm, the result should still be the same but since the functions are
allowed (or, AFAIK, are not disallowed to) have side-effects I don't
think the above would be kosher.

One minute ;) ...
The pseudo-code above doesn't exist yet, and it's not really the most important
issue, now, IMHO. Or, better, it may be interesting from the performance point
of view, not from the conformance point of view.


What we are really trying to clarify is if, overall, num_put::do_put should
behave as-if widen(char) is called (22.2.2.2.2, p14 seems to imply that) or
instead we are allowed to use the array version for performance sake.

In other terms, your late-2002 snippet:

struct Ctype: std::ctype<char>
{
char do_widen(char c) const {
return 'A' + c % 26;
}
};

int main()
{
std::locale loc(std::locale::classic(), new Ctype);
loc = std::cout.imbue(loc);
std::cout << 123 << '\n';
std::cout.imbue(loc);
}

what is supposed to output? "123" or "XYZ"? Is actually malformed ;)?

Paolo.


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