typeid of generic types

  • Thread starter Thread starter Ralf Propach
  • Start date Start date
R

Ralf Propach

Hi,

in C# I can write
Type listType = typeof(System.Collections.Generic.List<>);

What is the equivalent in C++?
I get compiler errors for all of the following:
Type listType = System::Collections::Generic::List::typeid;
Type listType = System::Collections::Generic::List<>::typeid;
Type listType = __typeof(System::Collections::Generic::List);
Type listType = __typeof(System::Collections::Generic::List<>);


TIA

Ralf
 
Ralf Propach said:
Hi,

in C# I can write
Type listType = typeof(System.Collections.Generic.List<>);

What is the equivalent in C++?
I get compiler errors for all of the following:
Type listType = System::Collections::Generic::List::typeid;
That's almost correct. You need a ^ however.

Type^ listType = System::Collections::Generic::List::typeid;

BTW: I'm not sure whether it's actually here to stay. The standard
has no provision for that (and IIRC Brandon said they didn't think
of it). Anyway, it might cause problems with class name injection
in templates. (i.e. should it selected the template or the specialization?)

-hg
 
Back
Top