> Dani?l Mantione wrote: > >>Won't the compiler sometimes be able to handle this smarter? When the code > >>generated for vector<TClassA> and vector<TClassB> is equivalent, we only > >>need > >>to include it once in the resulting executable, right? The only thing is we > >>have to see when this situation occurs. > > > > These tricks have been used in some C++ compilers with very limited > > success. The problem is that class_a has a different virtual > > methods/constructors/destructors than class b, so the code to be generated > > for them will be different, even though they are still just basically > > arrays of pointers. > > If a class only uses the :=, = and <> operators on the generic type, the > code could be the same for all specializations for classes, or am I > mistaking here? (The only problem is RTTI perhaps.)
Only when they are the same operations. This is why .NET uses interfaces with these operators in. Then they only need one code instance per interface instead of per class. But they can instantiate and kill that code runtime (JIT). _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel