typeid of generic types

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
 
H

Holger Grund

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top