|
Boost : |
From: Jeremy Siek (jsiek_at_[hidden])
Date: 2000-11-20 10:31:54
Hi John,
I agree, misconcept checking is definitely something to
watch out for.
I think the standards requirements for lower_bound
should be reworded. It says that T should be LessThanComparable,
but that is somewhat irrelevant to the functionality
required in lower_bound. What lower_bound should require
is something I would call
LeftLessThanComparable<target_type, value_type>
which just requires that target_type be comparable
"on the left" with the value_type.
template <class XX, class YY>
struct LeftLessThanComparable_concept
{
void constraints() {
require_boolean_expr(b < a);
}
bool boolean;
XX a;
YY b;
};
It's too bad concept checking wasn't around when
the standard was being written. It would have
caught a lot of these kind of errors.
Cheers,
Jeremy
On Mon, 20 Nov 2000, John E. Potter wrote:
> On Mon, 20 Nov 2000, John Maddock wrote:
>
> > For example an input iterator has to be used in a particular way
> > - with alternating calls to operator++ and operator*
>
> I don't think so. That is the only safe way to use an output
> iterator; however, it does not apply to input iterator. Example: wc -w
>
> cout << distance(istream_iterator<string>(cin),
> istream_iterator<string>()) << endl;
>
> I see misconcept checking as a real problem. It has been reported that
> the stl_port rejects lower_bound when the target type does not match
> the iterator value_type. In spite of the fact that the compare object
> supports target type, value_type in either order.
>
> John
>
>
>
>
>
----------------------------------------------------------------------
Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
Ph.D. Candidate email: jsiek_at_[hidden]
Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk