On Tue, 2003-05-20 at 17:56, David Abrahams wrote:
Tarjei Knapstad
writes: On Mon, 2003-05-19 at 21:34, David Abrahams wrote:
Tarjei Knapstad
writes:
<snip>
and it's easy to see that pop_front<List>::type is evaluated whether List is empty or not.
...is it?
Sure! What happens when you try to Reverse an empty sequence?
Ah yes certainly, but in my real case (i.e. not this Reverse thingy), giving an empty sequence means you're trying to generate illegal code, so it's actually a positive side effect there (sorry, forgot to mention this...)
I thought apply_if<> only instantiated either the 'true' or 'false' statement depending on the condition.
Yes, but it doesn't inhibit evaluation *lexically*. Whenever you write ::type, you get a non-lazy evaluation. In fact, your apply_if is not delaying anything, since you greedily evaluate the 2nd argument, and the first argument is already the right type. You'd get the first argument correctly because
Oh, and please, do yourself a favor and follow the MPL metafunction protocol! That means your result is called "::type", not "::Type".
Yes, but this goes againts our own coding standards unfortunately (all types are captialized). I'm considering a modification to our standards though, in that stuff that models STL concepts (like iterators etc.) should be named like they are in the STL. I'm still undecided on what will end up being less confusing... On a sidenote, I seem to remember from the ACCU conf. in Oxford this year that you were preparing a book on the MPL? Is it in it's early stages, or do you have any rough date for it's completion? (It certainly looks like I could need a copy ;) ) Thanks, -- Tarjei