std::auto_ptrで演算子[]が許可されないのはなぜですか?
#include <iostream>
using namespace std ;
template <typename T>
void foo( T capacity )
{
auto_ptr<T> temp = new T[capacity];
for( size_t i=0; i<capacity; ++i )
temp[i] = i; // Error
}
int main()
{
foo<int>(5);
return 0;
}
Microsoft Visual C++ 2010 でコンパイルされています。
エラー:エラー C2676: バイナリ '[' : 'std::auto_ptr<_Ty>' は、この演算子または事前定義された演算子に受け入れられる型への変換を定義していません