Re: template and static methods
On Apr 22, 2:08 pm, Michael DOUBEZ <michael.dou...@free.fr> wrote:
James Kanze wrote:
On Apr 22, 12:13 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
red floyd wrote:
I might add that you should never have to type the include guard
anyway. Just configure your editor to insert it automatically
any time you open a new .hh (or .hpp, or whatever) file, just
like you do to get the copyright notices and stuff in the code.
(This is trivial with vim and emacs, but I imagine any decent
editor would support it.)
(Under Unix, I use
guard3=` dd bs=24 count=1 if=/dev/random 2> /dev/null |
tr '\000-\377' "${alnum}${alnum}${alnum}${alnum}0-7" `
Or simply:
`xxd -u -c 24 -l 24 -p /dev/random 2> /dev/null`
But you'd still have to write xxd:-). It's not standard Unix.
Of course, you can get more or less the same thing by piping od
through sed (to strip the offset and the blanks). With the same
problem: it uses a set of a lot less characters (16 instead of
62), so you need a lot more characters to achieve the same
amount of variation. (In my version, "alnum" is "a-zA-Z0-9".)
My original version used od through sed; I then replaced sed
with an awk script which picked characters out of a table of all
the alphanumerics, precisely to increase the number of
characters used (and thus the variation). Then Genny proposed
the above to me, which is even simpler.
Note that with all of these variants, you can run out of
entropy, with the result that reading /dev/random becomes
inordinately slow. If I'm generating code from C++, I'll use
/dev/random to seed the random number generator, and use that
for the actual random characters. Of course, in C++, you can
get even fancier, ensuring that the first character is alpha,
using '_' as well (but ensuring that it doesn't occur twice in
succession), etc. For the most part, this is probably over
perfectionnism, but why not, if you feel like it?
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34