[MPL, TypeTraits] Absurd template nesting on GCC 2.95

Hi all, I'm working on some code which if naively implemented would involve deep template nesting. Since I can't get a version using MPL algorithms to work on BCC 5.5.1 or VC6 , I wrote out the algorithm with hand-coded loop unrolling. It worked beautifully on a whole bunch of compilers, but when I tried it on GCC 2.95 I found I had to set the template nesting depth to 34 to get it to compile. The same code worked on GCC 3.2 with the depth restricted to 11. After making a few changes, I got the depth on GCC 2.95 (and 3.2) down to 7. One of the changes I made was to switch from using is_based_and_derived to a hand-rolled version restricted to a particular base type. This last change eliminated 11 levels of nesting on GCC 2.95 and 4 on GCC 3.2, although is_based_and_derived had been used in only one place, with fairly simple types, at the center of the algorithm. So I am wondering: is GCC 2.9x known to to be wasteful with respect to template nesting? Also, are the workarounds for GCC 2.9x in Type Traits or MPL known to add a lot of extra template nesting? Jonathan

Jonathan Turkanis wrote:
Hi all,
I'm working on some code which if naively implemented would involve deep template nesting. Since I can't get a version using MPL algorithms to work on BCC 5.5.1 or VC6 , I wrote out the algorithm with hand-coded loop unrolling.
IMHO it would be better to try to get the MPL version to work rather than rolling your own. What problems are you having with VC6? -- Daniel Wallin

"Daniel Wallin" <dalwan01@student.umu.se> wrote in message news:40272F00.2040102@student.umu.se...
Jonathan Turkanis wrote:
Hi all,
I'm working on some code which if naively implemented would involve deep template nesting. Since I can't get a version using MPL algorithms to work on BCC 5.5.1 or VC6 , I wrote out the algorithm with hand-coded loop unrolling.
IMHO it would be better to try to get the MPL version to work rather than rolling your own.
I agree in general. After struggling a bit Borland and VC6 for a while I decided to try a hand-writen version, which turned out to be very simple to write -- it just took a few minutes. The workarounds for Borland 5.6.4 and VC6 were straigforward; getting it to work on Borland 5.5.1 and GCC 2.95 was the real pain. I've never used Borland 5.5.1 or GCC 2.95 before this week, so I'm not surprised it took me a while to get them to work.
What problems are you having with VC6?
About 1500 lines of errors relating to MPL internals which I don't understand. The usual stuff: 'xxx has no member yyy', where xxx is some undocumented template. I can usually get MPL code to work on VC6, but not because I understand the error messages. ;-) I didn't really try that hard to fix it today, because I remember spending a lot of time on it several months ago. The hand-written version seems to be quite fast and stable now. I may ask you for help if I decide to work on it again. I was just a bit surprised to find the enormous depth of nesting on the old GGC. Best Regards, Jonathan
participants (2)
-
Daniel Wallin
-
Jonathan Turkanis