我需要实现迭代器,我没有时间制作好的迭代器类,所以我决定只返回指针.就是这样的
int* begin() { return p; }
但我希望它们像通常的stl迭代器一样运行
*++begin(); // doesn't work because returned pointer isn't l-value std::vector<int> vi{ 0,1 }; *++vi.begin(); // works fine int* p = begin(); *++p; // works fine as well
我怎样才能做到这一点?