
Joachim Faulhaber
Hi Jerry,
...
In the Party example a boost::itl::set<string> is used to store the names of the guests because it supports += as set union. In that example you can just as easily use: struct GuestSetT : public std::set<string> { std::set<string> & operator += (const std::set<string> & right) { insert(right.begin(), right.end()); return *this; }}; My question is, does this example really benefit from using itl::set? I do see value in itl::set and itl::map on their own but except this one use there aren’t any examples that show why they would suit a particular application.
In the ITL not only operator += but also -= and &= are "pervasive" and they are expected as defaults for interval maps in order to perform "aggregate on onverlap", where the operator is passed to combine associated values in case of overlap of intervals. One of the reasons to introduce itl::set and itl::map was to support these operators, so that interval maps of sets or even interval maps of maps of ... work "out of the box" without the need for the user to write adapter code (like the one proposed above).
Other reviewers have criticised these "element containers" of the ITL as well. I am going to consinder their arguments in a redesign of the ITL's interface. One possibility that I will most likely provide is adaptercode for std::containers directly that implements the operators that are expected for "aggregate on overlap".
...
Thank you again for your review
Best regards, Joachim
Joachim, I wasn't complaining that itl::set was used in the example. I just wanted to understand: a) why it was used instead of an adapter class - a more detailed comment in the example would suffice. Or maybe a comment that they are just adapter classes in the reference docs for itl::set and itl::map? b) what else I could use them for since there are no examples for them (some examples would be great) I am sure there are really useful things that can be done with them besides the use in the Party example. Jerry