Hi,
I have a function as below:
Where Blob is a simple structure.Code:void f ( std::vector<Blob> *blobsPtr ) { // create the vector to store every pair of pointers to Blobs vector<Blob*[2]> pairs; // create a vector of pairs of Blob pointers, total of (num of Blobs choose 2) for (vector<Blob>::size_type i = 0; i < blobsPtr->size() - 1; i++) for (vector<Blob>::size_type j = 0; j < blobsPtr->size(); j++) { const Blob *b[2]; b[0] = &(blobsPtr->at(i)); b[1] = &(blobsPtr->at(j)); pairs.push_back(b); } // examine each pair and remove ones that fail the test }
The goal of the function is to take all of the elements in the vector referenced by blobsPtr, and first create a vector of pairs of pointers to Blobs. In other words, create a vector that has every pairwise combination of Blobs (as pointers). Then I want to do some tests and remove the elements of 'pairs' that fail the tests. Finally, I want to delete all the Blobs that failed the test from the vector pointed to by 'blobsPtr'.
Whew!
The error I am getting with the current version is "cannot convert parameter 1 from 'const Blob *[2]' to 'Blob *const (&)[2]" when I try to do the push_back.
I'm starting to get confused, so any help would be appreciated. Or perhaps I'm going about this totally wrong. The thing is I don't want to copy all the Blobs when I'm creating the pairwise vector, because it's just a waste of memory.
Thanks.