views:

156

answers:

3

hello.

In meta-programming number of classes grows quite fast. Is maximum number of classes modern compiler allows, for example g++, something to be concerned about?

Thank you

A: 
egrunin
+2  A: 

I'd guess this question is best answered by the standard published by the C++ committee. But looking at this place, I can't see any upper limit on the number of classes although there is minimum quantity limit on many items (saying at least the given number of items of each type should be supported by the compiler but that is not a binding limit). If your compiler can support these minimum limits, you should be OK.

But what factors would have the say on the upper limits on the number of classes kindles my academic curiosity. I'd be glad to know if a compiler guru can answer that.

vpit3833
The implementation quantities are not really hard minimums; they are merely _recommended_ minimum quantities; if an implementation doesn't meet the minimum for something, it should document what quantity it can support.
James McNellis
You got me, I should have read a second time to have not missed it. Anyway, corrected the answer to reflect this point.
vpit3833
+1  A: 

If you run on a 64-bit computer, you're unlikely to run out of any limitation in any modern compilers. Type information is likely to be dynamically allocated, rather than put into some hard-coded limited-size container.

I can think of some systems that might conceivably grow to be hard to compile in a 2 GB memory space as you'll have for a 32-bit computer. However, even though I've worked on some pretty big C++ code bases with lots of template metaprogramming, that hasn't actually been a problem in practice. The slowness of compilation and the annoyance of debugging probably will kill you before memory size does :-)

Jon Watte