|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-05-17 06:54:32
"Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> "Eric Niebler" <eric_at_[hidden]> wrote in message
> news:428926DB.2090108_at_boost-consulting.com...
> |
> |
> | Yes. It's exactly the same situation. You are giving collection<X>
> | different semantics than collection<Y>.
>
> I guess my objection is to the use "exactly".
>
> If I have
>
> template< class T >
> class my_vec
> {
> std::vector<T> vec;
> };
>
> then I might need some traits for dealing with the bool case.
What kind of traits?
> If I have
>
> template< class Range, class OutIter >
> void copy( const Range&, OutIter );
>
> then I just need to be able to say what a Range means.
Yes, that's what makes your case worse. It doesn't just change the
interface details as with vector<T>, it changes the fundamental
meaning of T[N], leading to potential undefined behavior in some very
common cases.
> I think it would be wrong for the algorithm to assume anything; that
> would not give the caller a chance to decide.
Then you can't decide anything about T[N] either. People use all
kinds of arrays with terminating sentinels, not just arrays of char.
> Yeah, sorry. I guess I was equally annoyed by the claim that we had
> a new problem simply by stating vector<bool> was a problem.
It's a valid claim, made without ad-hominem overtones.
> I don't see that close an analogy and so the argument made by Dave
> could be used to to argue for anything.
If you don't see the analogy, you're not looking hard enough. It
happens whenever a whole category of types gets a particular treatment
by generic code, but just a few outliers in that category get a
different treatment. And as I said in my previous posting, the
problem is much worse your case because there's no useful underlying
concept that is modeled by both the ordinary array and the
null-terminated string.
> I don't think the decisions of the range library was a big issue
> during the review; Peter Dimov was, I think, one who said something
> along your opinion.
Peter Dimov is one of those annoying people, you'll come to learn, who
is almost always right. I wouldn't draw too many conclusions from the
fact that perhaps nobody else objected to the design. Peter is often
ahead of the perceptual curve, and some of us weren't participating in
the review.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk