【发布时间】:2013-12-17 18:19:19
【问题描述】:
我正在尝试重载运算符 []。以下代码无法编译,我怀疑我只是犯了语法错误,但我需要帮助了解我做错了什么以及为什么。
以下是相关代码的摘录:
template <typename T>
class MultiDimArray{
public:
template <typename ...I>
T& operator[](const size_t firstIndex,const size_t ...I);
//...
}
template <typename T> //class's template parameter(s)
template <typename ...I> //function's template parameter(s)
T& MultiDimArray<T>::operator[](const size_t firstIndex,const size_t ...I){
//...
}
注意 1:我正在尝试遵循 this answer 顶部建议的可转换为类型检查的编译时间。
【问题讨论】:
标签: c++ c++11 operator-overloading variadic-templates subscript-operator