traits问题
#include <iostream> #include <typeinfo>
#include <iterator>
using namespace std;
class A
{
public:
A(int i=10)
{
k=i;
}
int k;
};
template<class it>
void fun(it)
{
typename iterator_traits<it>::reference reference;//编译时这行总是提示 [Error] 'reference' declared as reference but not initialized
cout<<typeid(reference).name()<<endl;
}
int main( )
{
A *a=new A(6);
fun(a);
}