"Beman Dawes" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 04:18 PM 2/2/2003, David Abrahams wrote:
>  >[...]
>  >Why can't operator T*() and operator[](size_t) coexist?
>
> They are ambiguous, or at least GCC, Intel, and Microsoft compilers
> think so, although Borland only warns and Metrowerks accepts.

I see.  That's what Comeau says too.  I was testing it with an int
parameter, in which case it compiles.

> [...]
> The only way to get it to work with both VC++ 6.0 and 7.0 is to
> remove the operator T*().

Ok.  I think this is possible without changing the inheritance hierarchy,
though.  We can disable operator T* using the disallow_conversion
policy, and I suspect we can disable operator[] by tweaking the
argument type like so (pseudocode):

class smart_ptr
{
private:
    class disable_index { };
    typedef if_<
        array_policy && disallow_conversion,
        std::size_t,
        disable_index const&
    >::type index_arg;

    // ...

public:
    T& operator[](index_arg)
    { ... }

    // ...
};

Dave



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to