I don't know if this exactly belongs on the Beginner's forum, but with respect to templates and the details of typedef I would certainly be regarded as a beginner, I think.
It is mostly just a question of curiosity, however:
You can use typedef to declare a short form of another type, like so: typedefunsignedint Uint;
But, is there any way to use it to declare something template like, to shorten templates? Something like this: typedef std::array<std::array<T,x>,y> grid<T,x,y>;
(Which of course doesn't work, but the expected functionality would be grid<int,9,9> referring to an std::array<std::array<T,x>,y>.)
Test it out yourself. I quickly tested @ ideone.com. See http://ideone.com/4z7qB . Something like that? I think you can only have templated classes, and this is why I added the class.
Gotta love C++11.
I tried out the first method, and it's a bit messier than what I wanted. An extra step added for no particular reason (in this case).
But the second method is exactly what I was looking for.
1 2 3 4 5 6 7
template<class T, unsignedint x, unsignedint y>
using grid2 = std::array<std::array<T, x>, y>;
int main() {
grid2<int,9,9> myGrid2;
return 0;
}
I'm still not sure how I feel about typedef's in general, but at least I can tell my friends who think macros are great one more alternative, if nothing else. And now I know a bit about templates!
Thanks for the help, webJose and firedraco.