From: Daryle Walker (dwalker07_at_[hidden])
Date: 2003-02-04 02:20:14
I haven't been following Boost that much lately. Spent the past few
days catching up.
Some people have been discussing changes to the algorithm used by
static_log2 lately. Actually, I've forgotten why I used the
implementation I did. I sometimes tend to be verbose in my code;
hopefully compilers can optimize some of it out. Also, when you see an
algorithm looking more complex than you think it should, be mindful
that the code may be bigger to workaround some gotchas that the simpler
alternative doesn't consider.
The newer code I've seen on the list uses the same ideas as the current
code, but there are enough differences that I have questions about.
1. The current static_log2_helper_t uses three template arguments, the
new code only uses two. I guess there's some merging of the Place and
Index uses; can you explain further.
2. The base case of the new code uses fully specialized
static_log2_impl<1,0>, while the current code uses a partially
specialized static_log2_helper_t<Val, Place, 1> (which requires
workarounds for some compilers). One of the posts implied that the "1"
in the first template argument is guaranteed in the usual
circumstances. Can you explain further, including how to ensure that
the usual circumstances occur.
3. One reason for the timing differences could be that the current code
has an extra masking step that the new code doesn't have. Is the
masking I'm doing really needed? Would commenting-out/changing that
part of the code give the speed boost you have?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk