【发布时间】:2010-06-17 06:26:06
【问题描述】:
有没有办法获取类模板参数的延迟类型?
template <class TPtr>
struct foo {
typedef TPtr ptr_type;
typedef ??? element_type; /* shall be the type of a deferred TPtr*/
};
所以foo<const char*>::element_type 产生const char,foo<std::vector<int>::iterator_type>::element_type 产生int。
我知道我可以将value_type typedef 用于 c++ 迭代器(如std::vector<int>::iterator_type::value_type),但原始指针没有 value_type typedef,所以我不走运。
【问题讨论】: