我想知道是否有可能有某种参数化的typedef。参数化typedef可能吗?
为了说明这一点,在我的代码我这个typedef:
typedef std::queue<std::vector<unsigned char>, std::deque<std::vector<unsigned char> > > UnsignedCharQueue;
正如你可以看到这是一个相当笨重的结构使的typedef才有意义。但是,如果我想要使用其他数据类型的队列,我需要事先定义它们。
所以我在想如果有可能使用这样的结构:
typedef std::queue<std::vector<T>, std::deque<std::vector<T> > > Queue<T>;
private:
Queue<unsigned char> mMyQueue;
类似像Java泛型。
[C++ template typedef]的可能重复(http://stackoverflow.com/questions/2795023/c-template-typedef) – 2013-04-30 18:40:26