|
Boost : |
From: Jan Gaspar (jano_gaspar_at_[hidden])
Date: 2005-04-20 05:54:34
Hi Fredrik,
I'm attaching the discussion during the formal review
regarding the comparison operators. But before you dip
into the reading, I'd like to say that my intension
was to write STL compliant container nothing less or
more and I'd like to stick with this.
Jan
Subject: RE: [boost] Formal Review: Circular Buffer
Date: Tue, 9 Mar 2004 09:44:34 -0800
From: "Powell, Gary" <powellg_at_[hidden]>
To: boost_at_[hidden]
Shouldn't the comparison functions allow the types to
differ? I mean
don't they still lexigraphically compare as long as
there is a comparison
function F that a F b for each element exists
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?
Therefore IMO, all of the comparison functions should
change from
template< typename T, typename Alloc>
bool operator F ( circular_buffer<T, Alloc> &lhs,
circular_buffer<T, Alloc> &rhs);
to
template< typename T1, typename Alloc1,
typename T2, typename Alloc2>
bool operator F ( circular_buffer<T1, Alloc1> &lhs,
circular_buffer<T2, Alloc2> &rhs);
Yours,
-Gary-
-----------------------------------------------
To: boost_at_[hidden]
From: "Pavel Vozenilek" <pavel_vozenilek_at_[hidden]>
Date: Tue, 9 Mar 2004 20:52:29 +0100
Subject: [boost] Re: Formal Review: Circular Buffer
Hmm, do you know a STL implementation/some container
with this feature? It may be often bug to compare
containers with
different types.
/Pavel
-----------------------------------------------------
Subject: RE: [boost] Re: Formal Review: Circular
Buffer
Date: Tue, 9 Mar 2004 13:55:15 -0800
From: "Powell, Gary" <powellg_at_[hidden]>
To: boost_at_[hidden]
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.
---------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk