Can a template parameter be restricted to primitive types?
-
Can I restrict a template parameter to primitive (or unmanaged) types only? Is it possible to enforce this condition so that I can take a pointer to it?
class Example where T : struct {
T* p;
}I get an error because
T
is a managed type. I understand this, but is there a way to tell the compiler that it's a native type (e.g.int
ordouble
)? -
Can I restrict a template parameter to primitive (or unmanaged) types only? Is it possible to enforce this condition so that I can take a pointer to it?
class Example where T : struct {
T* p;
}I get an error because
T
is a managed type. I understand this, but is there a way to tell the compiler that it's a native type (e.g.int
ordouble
)?No, sorry. You can't.
Deja View - the feeling that you've seen this post before.
-
No, sorry. You can't.
Deja View - the feeling that you've seen this post before.