Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-05 13:05:00


From: "Peter Dimov" <pdimov_at_[hidden]>

> From: "David Abrahams" <dave_at_[hidden]>
> > operator[] shouldn't be instantiated unless you try to use it. Why are
you
> > trying to use it?
>
> The definition is not instantiated unless used, but the declaration is
> always instantiated. I had a similar problem with
> shared_ptr<void>::operator*.

Aha.

I've been using a trick in the Boost.Python library which might apply here:

template <class T, class Result>
struct dependent {
    typedef Result type;
};

now you can use dependent<T,X>::type to declare a return type of X which is
dependent on a template parameter of the function, e.g.:

  typename dependent<Policies,value_type>::type operator[](difference_type
n) {
    ...
  }

This trick is also nice for breaking #include dependencies, since the
definition of X isn't needed in order to use it.

If OP tries this and it works for his problem I'd be happy to accept a
patch.

-Dave

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


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