A simple example:
template // this template parameter should be usable outside!
struct Small {
typedef _X X; // this is tedious!
X f
Depending on what you're doing, template template parameters might be a better option:
// "typename X" is a template type parameter. It accepts a type.
// "template class SomeSmall" is a template template parameter.
// It accepts a template that accepts a single type parameter.
template class SomeSmall>
struct Big {
SomeSmall bar; // We pass X to the SomeSmall template.
X toe; // X is available to this template.
};
// Usage example:
template
struct Small {
X foo;
};
struct MyType {};
// The foo member in Small will be of type MyType.
Big big;