Skip to content

Make AggregateSensor::SensorIterator satisfy LegacyInputIterator and input_iterator

ksystemstats!21 (merged) requires AggregateSensor::SensorIterator being compatible with stl algorithms, so I looked it up and it seems that I only need to tag it and add some methods. Doing so I found out two problems tho:

  • It seems that the iterator needs to implement operator->(), but I don't think it's actually used anywhere in the stl, because you should know the name of the methods of the value_type of the iterator, and that would make those algorithm not general.
  • operator*() should return a reference to the value_type of the iterator.

Both of these are problems because SensorProperty only provides the value of the sensor by value, not by reference, so SensorIterator can only do the same. So I was wondering what to do now: ignore these problems (it seems to work anyway, at least tested against ksystemstats!21 (merged), while being technically not correct) or change SensorProperty and make it return a const reference too and use it in SensorIterator?

Edited by Alessio Bonfiglio

Merge request reports

Loading