c++ - typedef 标准容器?

标签 c++ templates typedef

我想做

typedef deque type; //error, use of class template requires template argument list
type<int> container_;

但是那个错误阻止了我。我该怎么做?

最佳答案

你不能(直到 C++0x)。但它可以模拟:

template<typename T>
struct ContainerOf
{
  typedef std::deque<T> type;
};

用作:

ContainerOf<int>::type container_;

关于c++ - typedef 标准容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/562209/

相关文章:

C++:传递 "typedef"定义的类作为参数

c++ - 重载策略类​​模板的成员函数

c++ - gcc 与 clang : noexcept parsed in unused template specialization when static casting

c++ - 标准中哪里说下面的 typedef 是有效的?

c++ - 在直接 x 中旋转 3D 网格

C++ 模板 : typename and function to map to int

c++ - 如何使用 typedef 完全隐藏特定类型?

c++ - 使用 `cstdarg` 中的宏访问普通函数参数是否合法?

c++ - 如何使用 MITK 作为库

c++ - 在进入 C++ 函数方面需要帮助