Re: [boost] Re: Re: [circular_buffer] comparison operators

Hi Frederik, the discussion didn't end up with a conclusion. (I appended all the submissions regarding this comparison operators issue.) In my opinion, there was an idea behind the fact the comparison operators don't work for different types at the time the STL was being designed. Although I don't know what idea it was. (Does anyone?) Regardless it was good or not I'd like the circular_buffer to behave the same way as other STL containers. I don't want to break the contract. On the other hand when we consider comparison between 2 circular_buffers of different types, why not to take it one step further and allow comparison of 2 different containers. E.g. circular_buffer<int> x = { 1, 2, 3}; deque<short> y = { 1, 2, 3}; x == y; // makes sense? It doesn't matter that the containers are of different types - it is about comparing content, isn't it? Jan --- Fredrik Blomqvist <fredrik_blomqvist@home.se> wrote:
-----------------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com

Jan Gaspar wrote:
Well, I don't think that's totally unreasonable. The big catch in this case though, is that it would require an "infrastrucure" around an is_range<> metafunction protocol to be used with enable_if (SFINAE) code in all the operators. This is a considerable larger effort than per container lhs/rhs type flexibility. Finally, my intention wasn't to make a big deal of this. I was mostly curios about rationales and the fact that many other components already use such a scheme, and that a recommendation for future components perhaps could be agreed upon. Regards // Fredrik Blomqvist

Hi Frederik! I realized there is no reason to implement the comparison operators - functions std::equal() and std::lexicographical_compare() do the job. std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); std::deque<short> d; d.push_back(1); d.push_back(2); d.push_back(3); std::lexicographical_compare(v.begin(), v.end(), d.begin(), d.end()); std::equal(v.begin(), v.end(), d.begin()); Jan --- Fredrik Blomqvist <fredrik_blomqvist@home.se> wrote:
-----------------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com
participants (3)
-
Fredrik Blomqvist
-
Jan Gaspar
-
Pavel Vozenilek