Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2002-02-24 08:25:45


From: "rogeeff" <rogeeff_at_[hidden]>
> > 1. I don't want the implicit conversion to the base.
>
> What wrong with that? Other than item 3? I would consider this as a
> useful feature allowing to pass container in old function expecting
> regular container.

Which is exactly what I want to avoid. Mainly because of 2 and 3.

> > 2. Sometimes the function needs to be more than a simple forward.
> Then
> > I don't want to "override" (i.e. hide) a non-virtual.
>
> What wrong with that? You are doing that already. but with private
> parent.

Yes, but I don't want to see

   void f( vector<foo*> &x ) { x.erase(x.begin()); }

  auto_vector<foo>::type y;
  y.push_back( new foo );
  f(y); // Memory leak.

Now you could argue that this is no different from allowing
y[0] = new foo; but I think it is. By not allowing the conversion,
we always know we have an auto_sequence so we know what we can do
safely. However the writer of f above wouldn't know whether they
were being passed an auto_vector.

> 1. Need to forward all the functions
> Now it's about 70-80 persent of all function you implemented.

Yes, but that's done now, so you don't need to worry about it :-)

> 2. Can't use custom function.
> Since you forward only some functions you can't use any custom
> function presented by base contaner. For example map::find, or any
> custom function in my custom container.

I envisaged doing this with and extended auto_sequence. Suppose you
have

  template< class T > class my_nifty_container {
    ...
    void some_func();
  };

then you could auto-ize this with

  template< class T > class my_auto_nifty_container
          : public auto_sequence< my_nifty_container<T*> >
  {
    // ... constructors ...
  
    using my_nifty_container<T>::some_func;
  };

Mark


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