【发布时间】:2019-10-12 00:29:38
【问题描述】:
是否可以在 c++ 中使用 using 关键字定义此类类型别名?
语法如何?我试过using const_type = typename const T::type 不行。
template <typename T>
class DoubleBuffer {
typedef T value_type;
typedef T& reference;
typedef T const & const_reference;
typedef T* pointer;
const_reference operator[](const size_t pos){
...
}
};
【问题讨论】:
-
using const_type = const typename T::type; -
using const_type = const T; -
你的问题不是很清楚。您是否尝试将示例中的所有
typedefs 替换为using关键字? -
@InnocentBystander 是的,但我真的很困惑何时使用
typename何时不使用。这似乎是我的代码的问题。 -
@evanxg852000 请参阅Dependent names 下的类型名称消歧器部分。
标签: c++ c++17 typedef type-alias