RE: [boost] Re: Formal Review: Circular Buffer

No, but just because the standard libraries scr*wed up is no reason to perpetuate the mistake. It's the rule of unexpected consequences. Is circular_buffer<int> x = { 1, 2, 3}; circular_buffer<short> y = { 1, 2 ,3}; x == y ?? or not? Sure looks like it should work. The VTL library does it IMO correctly, allowing that if there is an operation T1 F T2, then V1 F V2 compiles. Otherwise you just force the user to write what should be library code. (Obviously swap can't do this unless the Allocators are the same.) template<class T1, class T2, class Alloc> void swap( circular_buffer<T1, Alloc> &lhs, circular_buffer<T2, Alloc> &rhs) { // do an element by element swap. // and insert for the leftover elements. } template<class T1, class Alloc> void swap<T1, T1, Alloc> ( circular_buffer<T1, Alloc> &lhs, circular_buffer<T1, Alloc> &rhs) { // swap the whole container. lhs.swap(rhs); } Yours, -Gary- -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Pavel Vozenilek Sent: Tuesday, March 09, 2004 11:52 AM To: boost@lists.boost.org Subject: [boost] Re: Formal Review: Circular Buffer "Powell, Gary" <powellg@amazon.com> wrote
Shouldn't the comparison functions allow the types to differ?
circular_buffer<T, MyAlloc> x; circular_buffer<S, YourAlloc> y;
bool b = x == y; for where the operator T == S is valid? And what does the allocator have to do with it?
Hmm, do you know a STL implementation/some container with this feature? It may be often bug to compare containers with different types. /Pavel _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (1)
-
Powell, Gary