File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,39 @@ class GenericPointer {
356
356
*/
357
357
bool operator !=(const GenericPointer& rhs) const { return !(*this == rhs); }
358
358
359
+ // ! Less than operator.
360
+ /* !
361
+ \note Invalid pointers are never lesser than valid ones.
362
+ */
363
+ bool operator <(const GenericPointer& rhs) const {
364
+ if (!IsValid ())
365
+ return false ;
366
+ if (!rhs.IsValid ())
367
+ return true ;
368
+
369
+ size_t i = 0 , lCount = tokenCount_, rCount = rhs.tokenCount_ ;
370
+ for (;;) {
371
+ if (!rCount)
372
+ return false ;
373
+ if (!lCount)
374
+ return true ;
375
+
376
+ if (tokens_[i].index != rhs.tokens_ [i].index )
377
+ return tokens_[i].index < rhs.tokens_ [i].index ;
378
+
379
+ if (tokens_[i].length > rhs.tokens_ [i].length )
380
+ return std::memcmp (tokens_[i].name , rhs.tokens_ [i].name , sizeof (Ch) * rhs.tokens_ [i].length ) < 0 ;
381
+
382
+ int cmp = std::memcmp (tokens_[i].name , rhs.tokens_ [i].name , sizeof (Ch) * tokens_[i].length );
383
+ if (cmp || tokens_[i].length != rhs.tokens_ [i].length )
384
+ return cmp <= 0 ;
385
+
386
+ lCount--;
387
+ rCount--;
388
+ i++;
389
+ }
390
+ }
391
+
359
392
// @}
360
393
361
394
// !@name Stringify
You can’t perform that action at this time.
0 commit comments