On Thu, Oct 6, 2011 at 6:23 PM, Darren Cook <[email protected]> wrote: >> It is not a big deal in this case but I am wondering how to define the >> population protocol using something like std::vector so that >> elementary protocols can be added or removed but each elementary >> protocol is read-only. >> ... like declaring the vector as std::vector<const ElemProt> but >> that doesn't seem to work in the push_back method for the vector. > > That should work (or I've misunderstood the problem). > "std::vector<const ElemProt>" means pass-by-value. Could that have > caused trouble? (E.g. if you didn't have a copy constructor defined.) > > If so, std::vector<const ElemProt*> might work? (Or better is vector of > smart pointers, so you don't have to worry about memory management.) > Or, define a copy constructor.
Thanks for the suggestion, Darren. One of my objectives is not to copy the objects. I have, in effect, created a copy constructor, to get around the problem of const'ness. I will look at your suggestion of a vector of smart pointers. _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
