example sources in both Python and C++

jay.krell at cornell.edu jay.krell at cornell.edu
Tue Oct 3 02:24:59 EDT 2000


-----Original Message-----
From: Daniel Berlin <dberlin at redhat.com>


>wmcclain at salamander.com (Bill McClain) writes:
>
>> > >      * Template arguments cannot be local types. That means STL
>> > >        containers must use types declared at the outer scope, which
>> > >        is ugly.
>Correct, this is indeed illegal.
>You cannot use function local types as template arguments, because it
>would make instantiation very evil.


I don't like this limit either, using local types for template parameters
has been just right for code of mine in the past. Why is it so hard to
implement? Can't the template instantiation be marked, like, static, just
like the local class's member functions, static locals, etc?

#include <vector>
int main() { class Local {}; std::vector<Local> v; return 0;}

VC5sp3
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 11.00.7022 for 80x86
z:\msdev5\VC\INCLUDE\vector(14) : error C2926: 'class main::Local' : types
with
no linkage cannot be used as template arguments
tt.cpp(2) : error C2926: 'class main::Local' : types with no linkage cannot
be u
sed as template arguments
tt.cpp(2) : error C2079: 'v' uses undefined class 'vector<int,class
std::allocat
or<int> >'

VC6sp4, only one error instead of three, nice little improvement
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
tt.cpp(2) : error C2926: 'class main::Local' : types with no linkage cannot
be u
sed as template arguments

 - Jay





More information about the Python-list mailing list