"" , , . , .
vector - . , - vector<int>, . - , , .
, T, , , , , , , . , - -arg -arg-, .
(, vector . , vector<int> vector<int, allocator<int> >, - , -arg .)
- , ideone. Exploder .
typedef list<int> list_of_ints;
Exploder . , Exploder<list_of_ints> :: type_1 - , , int. ( ) - allocator<int> Exploder<list_of_ints> :: type_2.
typedef Exploder<list_of_ints> :: type_2 should_be_an_allocator_int;
, , , , int Exploder< should_be_an_allocator_int > :: type_1, allocator . allocator<double>.
typedef Exploder< should_be_an_allocator_int >
:: rebind<double> :: type should_be_an_allocator_double;
, list<...,...> , , , .
, , list<int> int double:
Exploder<list_of_ints> :: rebind<double, should_be_an_allocator_double> :: type
, , typeid(...).name() , . , .
( , , - , . , .)
( . , allocator, -, rebind, . , , rebind)
Exploder
. , ideone .
template <class>
struct Exploder;
template<class T, template<class> class Template>
struct Exploder< Template<T> > {
static const char * description() { return " One-arg template. Arg 1 is a type "; }
typedef T type_1;
template <class V>
struct rebind {
typedef Template<V> type;
};
};
template<class T, class U, template<class,class> class Template>
struct Exploder< Template<T,U> > {
static const char * description() { return " Two-arg template. All args are types, as opposed to being (unapplied) templates. "; }
typedef T type_1;
typedef U type_2;
template <class V,class W>
struct rebind {
typedef Template<V,W> type;
};
};
template<class S, class T, class U, template<class,class,class> class Template>
struct Exploder< Template<S,T,U> > {
static const char * description() { return " Three-arg template. All args are types, as opposed to being (unapplied) templates. "; }
typedef S type_1;
typedef T type_2;
typedef U type_3;
};