|
Boost : |
From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2003-02-02 23:40:31
"Beman Dawes" <bdawes_at_[hidden]> wrote in message
news:4.3.2.7.2.20030202153034.022fcfd0_at_mailhost.esva.net...
> Here is the problem:
>
> If T is not an array, the interface must supply:
>
> T& operator*() const;
> T* operator->() const;
>
> If T is an array && conversion to T* is not desired, the
> interface must supply:
>
> T& operator[](size_t i) const;
>
> If conversion to T* is desired, the interface must supply:
>
> operator T*() const;
>
> In other words, there are four interface combinations:
>
> When T is not an array && conversion to T* is not desired:
>
> T& operator*() const;
> T* operator->() const;
>
> When T is not an array && conversion to T* is desired:
>
> T& operator*() const;
> T* operator->() const;
> operator T*() const;
>
> When T is an array && conversion to T* is not desired:
>
> T& operator[](size_t i) const;
>
> When T is an array && conversion to T* is desired:
>
> operator T*() const;
That very nicely clarifies the requirements. I don't have time to munch on
a detailed solution, but let me add this: operator[] doesn't have to be a
member, which might simplify things considerably.
By and large, I believe "smart pointers to arrays" are an oxymoron and
should not be supported.
Andrei
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk