I've seen this in a lot of example code:
but I don't quite understand why you would default it to void?Code:template <typename T=void>
You can create a void* variable, but not a void variable, so what's going on?
I've seen this in a lot of example code:
but I don't quite understand why you would default it to void?Code:template <typename T=void>
You can create a void* variable, but not a void variable, so what's going on?
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
What about:
Code:class TemplateClass { T *test; };
The only thing I could imagine is when T is declared as a variable like that, but then why use void* if you're using a template? Aren't void* pointers more useful in C than in C++?
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Hmm brewbuck may have a point. But I'd rather do that something like this:
Rather than defaulting to void and declaring a variable that wouldn't be allowed.Code:template<typename T> class SomeClass; template<> class SomeClass<AllowedType1> { };
But, true, void pointers can often be avoided in C++. So the system you read it at would probably be badly designed anyway.