我有以下设置:
auto comp = [](const vector<int>& a, const vector<int>& b) -> bool
{ return a.size() < b.size(); };
auto path = std::set <vector<int>, decltype(comp)> (comp);
当我尝试从设置的任务中获取第一个元素时
tasks.begin() this will return an iterator of the set
另外,当我再次尝试访问集合的向量时:
tasks.begin()->begin() this will only return an iterator of the vector.
如何获得集合中的第一个元素而中间没有任何迭代器?
你不能 访问a中元素的唯一方法std::set
是通过以下方法:begin,end,cbegin,cend,rbegin,rend,crbegin,creend,insert,emplace,emplace_hint,擦除,find,equal_range,lower_bound和upper_bound。它们中的每个都返回一个迭代器,一对迭代器或一对带有迭代器和布尔值的对象。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句