Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison include/llvm/Support/YAMLParser.h @ 100:7d135dc70f03
LLVM 3.9
author | Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 26 Jan 2016 22:53:40 +0900 |
parents | afa8332a0e37 |
children | 1172e4bd9c6f |
comparison
equal
deleted
inserted
replaced
96:6418606d0ead | 100:7d135dc70f03 |
---|---|
303 /// | 303 /// |
304 /// BaseT must have a ValueT* member named CurrentEntry and a member function | 304 /// BaseT must have a ValueT* member named CurrentEntry and a member function |
305 /// increment() which must set CurrentEntry to 0 to create an end iterator. | 305 /// increment() which must set CurrentEntry to 0 to create an end iterator. |
306 template <class BaseT, class ValueT> | 306 template <class BaseT, class ValueT> |
307 class basic_collection_iterator | 307 class basic_collection_iterator |
308 : public std::iterator<std::forward_iterator_tag, ValueT> { | 308 : public std::iterator<std::input_iterator_tag, ValueT> { |
309 public: | 309 public: |
310 basic_collection_iterator() : Base(nullptr) {} | 310 basic_collection_iterator() : Base(nullptr) {} |
311 basic_collection_iterator(BaseT *B) : Base(B) {} | 311 basic_collection_iterator(BaseT *B) : Base(B) {} |
312 | 312 |
313 ValueT *operator->() const { | 313 ValueT *operator->() const { |
324 operator ValueT *() const { | 324 operator ValueT *() const { |
325 assert(Base && Base->CurrentEntry && "Attempted to access end iterator!"); | 325 assert(Base && Base->CurrentEntry && "Attempted to access end iterator!"); |
326 return Base->CurrentEntry; | 326 return Base->CurrentEntry; |
327 } | 327 } |
328 | 328 |
329 /// Note on EqualityComparable: | |
330 /// | |
331 /// The iterator is not re-entrant, | |
332 /// it is meant to be used for parsing YAML on-demand | |
333 /// Once iteration started - it can point only to one entry at a time | |
334 /// hence Base.CurrentEntry and Other.Base.CurrentEntry are equal | |
335 /// iff Base and Other.Base are equal. | |
336 bool operator==(const basic_collection_iterator &Other) const { | |
337 if (Base && (Base == Other.Base)) { | |
338 assert((Base->CurrentEntry == Other.Base->CurrentEntry) | |
339 && "Equal Bases expected to point to equal Entries"); | |
340 } | |
341 | |
342 return Base == Other.Base; | |
343 } | |
344 | |
329 bool operator!=(const basic_collection_iterator &Other) const { | 345 bool operator!=(const basic_collection_iterator &Other) const { |
330 if (Base != Other.Base) | 346 return !(Base == Other.Base); |
331 return true; | |
332 return (Base && Other.Base) && | |
333 Base->CurrentEntry != Other.Base->CurrentEntry; | |
334 } | 347 } |
335 | 348 |
336 basic_collection_iterator &operator++() { | 349 basic_collection_iterator &operator++() { |
337 assert(Base && "Attempted to advance iterator past end!"); | 350 assert(Base && "Attempted to advance iterator past end!"); |
338 Base->increment(); | 351 Base->increment(); |