typedef with template functionality

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:
typedef unsigned int 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>.)

Thanks!
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.
Not in C++03, but in C++11 they added that feature. If I am understanding you correctly, anyway.

See: http://www2.research.att.com/~bs/C++0xFAQ.html#template-alias
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).
1
2
3
4
5
6
7
8
9
10
template<class T, unsigned int x, unsigned int y>
class UType1 {
public:
    typedef std::array<std::array<T, x>, y>  grid1;
};

int main() {
    UType1<int,9,9>::grid1 myGrid1;
    return 0;
}


But the second method is exactly what I was looking for.
1
2
3
4
5
6
7
template<class T, unsigned int x, unsigned int 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.
Topic archived. No new replies allowed.