Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-01-22 07:56:59

Daryle Walker wrote:
> On 1/20/04 10:05 PM, "Howard Hinnant" <hinnant_at_[hidden]> wrote:
>> But I suggest an alternative interface (with similar functionality):
>> move_ptr<T>
>> move_ptr<T[]>
>> The advantage of my suggestion boils down to nothing more than
>> syntax. There are no generic coding advantages that I am aware of.
>> I simply submit that S<T[]> is slightly more intuitive than
>> S_array<T>.
> I think the reverse; that "S<T[]>" is worse, because it's
> anti-intuitive! When I see a specialization, I think of something
> that has the same interface, but with some sort of optimized
> implementation.

That's what I said at the time Howard first proposed ptr<T[]>, too. But...

> Your idea is bad because you're deliberately giving
> this specialization a _different_ interface. It's worse than the
> "std::vector<bool> sucks compared to the unspecialized
> std::vector<T>" quirk (vector's problem is in the subtle difference
> in the dereferencing interfaces).

... this is not true at all. The problem with vector<bool> is that the
primary template generates a perfectly fine vector<bool>, but the
specialization shadows that with something that is incompatible (not a
vector<>, not even a standard container w.r.t. container requirements.)

ptr<T[]>, as generated by the primary template, doesn't make sense. If your
intuition tells you that it has the same interface, your intuition is wrong,
because it can't.

Boost list run by bdawes at, gregod at, cpdaniel at, john at