模板类std::iterator设置为在C++ 17中弃用.为什么这样?它是确保std::iterator_traits工作的一种方便方法,特别是如果您可以使用默认模板参数.在C++ 17中还有其他一些方法吗?
我有像这样的数组:
template<class T> class F
{
...
bool isSet() { return set_; }
T& GetVal() { return val_; }
private:
T val_;
bool set_;
...
}
F<S1> arr1[10];
Run Code Online (Sandbox Code Playgroud)
我正在寻找一个迭代器(或类似迭代器的类)来简化以下内容:
F<S1>* cur = arr1[0];
while(cur.IsSet())
{
S1* ptr = cur->GetVal();
// do something with ptr
cur++;
};
Run Code Online (Sandbox Code Playgroud)
想要更清洁的东西可以使用不同类型的S1,S2等.