Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2003-02-02 22:00:27

"Beman Dawes" <bdawes_at_[hidden]> wrote in message
> 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
    class disable_index { };
    typedef if_<
        array_policy && disallow_conversion,
        disable_index const&
>::type index_arg;

    // ...

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

    // ...


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