EDIT (thanks to Barry in comments) I need to copy FLANN search indices to use them in a vector but it is producing an access violation when the copies go range. The minimal code that crashes is:
#include<flann\flann.hpp>
#include<vector>
const int samplesize=10;
const int dimension=3;
int main(int argc, char* argv[])
{
//fill a pointer to doubles with whatever
double * data=new double[samplesize*dimension];
for(int i=0; i<samplesize*dimension; ++i)
{
data[i]=1;
}
// make a FLANN search index from that data
flann::Matrix<double> datamat(data,samplesize,dimension );
flann::Index<flann::L2<double> > ind(datamat, flann::KDTreeIndexParams(4));
flann::Index<flann::L2<double> > ind2(ind);
return 0;
}
I would be grateful if anyone can tell me how to stop this
The answer seems to be that I just shouldn't use the copy constructor for Index because it copies a pointer and the destructor deletes that pointer (the FLANN programmers violated the rule of three). Working around it with a vector of pointers (or boost shared pointers) seems to do what I need