[...]
I've find locale support to still be a major portability issue.
Doesn't that have other problems (such as not distinguishing
Norwegian from English in programs that deal with input from
both languages)?
You can change the global C locale as often as you want. Of
course, it's global state, which does introduce some issues in
the case of a multi-threaded application.
If code doesn't work "in general" because implementations are
deficient, you are screwed anyway.
No, the code doesn't work in general because it contains
undefined behavior (at least if Alf is talking about what I
think he's talking about). You can't include <cctype>, and
expect to be able to pass toupper (or std::toupper) to
std::transform, even if it might seem to work in simple cases.
(Any standard header may include <locale>, and once <locale> is
included, type deduction for std::transform fails.) And of
That's interesting. Where would one need to add that?
Everywhere the "C" locale isn't appropriate. A call to
setlocale is the first line in main in most C programs; in C++,
you'd probably want to replace it with:
std::locale::global( std::locale() ) ;
Except that as Alf says, you can't really count on std::locale
working the way it should.
Incorrect: there is no technical reason to avoid "void".
Still, it's a C-ism
. There isn't a technical reason, but
there is a stylistic one: it communicates the wrong message.
(It says that you're a C hacker who doesn't really understand
C++. I know that this isn't the case in your case, but that's
the way most people will read it.)
I never learned C, but I happen to like this keyword here to
distinguish definitions from call in a grep-able way.
That's easy:
int
main()
and grep ^main. That's been the rule in every shop I've worked
in, since my earliest days in C. The name of the function in a
function definition is always in column 1; the name of a
function is never in column 1 otherwise (generally as a result
of other formatting rules).
In any case, it's a habit and I am unlikely to change since it
never caused any problems.
What if your employer imposes coding guidelines that ban it
?
Or your collegues start treating you badly because they don't
like it
?