Why operator [] is not allowed on 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;
}
Compiled on Microsoft Visual C++ 2010.
Error: error C2676: binary '[' : 'std::auto_ptr<_Ty>' does not define this operator or a conversion to a type acceptable to the predefined operator