[ZOOM] pointers

Adam Dickmeiss adam at indexdata.dk
Thu Nov 1 12:18:55 CET 2001


On Thu, Nov 01, 2001 at 11:08:56AM +0000, Ashley Sanders wrote:
> Okay, why I think we need pointers to resultSets.
> 
> Taking my little example function of a few days ago
> 
>   void foo (const vector<connection *> &vCon,
>             query *psQuery,
>             vector<resultSet *> &vSet)
>   {         
>      vector<connection *>::iterator pvCon;
>      for (pvCon = vCon.begin() ; pvCon != vCon.end () ; ++pvCon)
>        vSet.push_back (pvCon->search (psQuery));
>   }
I may be in trouble for my lack of STL knowledge. But if you'd
like a pointer to a resultSet you can do that with new operator (on the
constructor or resultSet). What I'm saying is that if you want them
you can have them. If want a local object you can do that too.

We can achieve that with one thing: a public constructor for
a resultSet. We could invent search1, search2, etc indefinitely for
all the variants of resultsets. That's a no go. And that's what
you're saying too (I think).

-- Adam

> I think it perfectly legitimate that a user would want
> to create an array of result sets. Or if you are using
> the STL then a vector of result sets.
> 
> If we change connection::search() to return a straight resultSet
> object rather than a pointer and change my vector vSet to
> vector<resultSet>, then the function becomes:
> 
>   void foo (const vector<connection *> &vCon,
>             query *psQuery,
>             vector<resultSet> &vSet)
>   {         
>      vector<connection *>::iterator pvCon;
>      for (pvCon = vCon.begin() ; pvCon != vCon.end () ; ++pvCon)
>        vSet.push_back (pvCon->search (psQuery));
>   }    
>        
> Not much difference there then, but I've just been playing
> with g++ 2.95.3 and the line:
> 
>        vSet.push_back (pvCon->search (psQuery));
> 
> when not using pointers calls a normal constructor once and the
> copy constructor twice (why twice I'm not sure.) As we've
> agreed that copy constructors on resultSets are banned, then
> I wouldn't be able to have my vector of resultSet objects.
> 
> I can't think of a way around this, other than using pointers.
> As far as I know vector<resultSet &> wont work -- g++ just
> barfs with a couple of screens of error messages if I try
> that. I presume it's because of the way containers are
> implemented in the STL.
> 
> Is that good enough reason -- or am I missing something
> blindingly obvious?
> 
> Ashley.
> 
> -- 
> Ashley Sanders                                a.sanders at mcc.ac.uk
> COPAC: A public bibliographic database from MIMAS, funded by JISC
>              http://copac.ac.uk/ - copac at mimas.ac.uk
> _______________________________________________
> ZOOM mailing list
> ZOOM at indexdata.dk
> http://www.indexdata.dk/mailman/listinfo/zoom

-- 
Adam Dickmeiss  mailto:adam at indexdata.dk  http://www.indexdata.dk
Index Data      T: +45 33410100           Mob.: 212 212 66



More information about the ZOOM mailing list