Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2004-01-21 16:46:43


On 1/20/04 10:05 PM, "Howard Hinnant" <hinnant_at_[hidden]> wrote:

[SNIP]
> That is, smart pointers to arrays of objects should not respect
> dervied-to-base conversions because the language does not do so for raw
> pointers.
>
> Therefore an interface should not imply that you can handle arrays of
> objects by simply customizing the deletion policy. Smart pointers to
> arrays of objects require a different interface, including:
>
> * no dervied-to-base conversions
> * no operator*()
> * no operator->()
> * operator[](size_t)
>
> One way to accommodate this need is to create different types like:
>
> scoped_ptr<T>
> scoped_array<T>
>
> 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>.
[TRUNCATE]

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. 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).

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk