|
-
December 7th, 2011, 06:32 PM
#11
Re: adding to vector of vector<int>, check if element already present
I am having some issues compiling. I am getting the following error,
Code:
In function `std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > add_atoms_to_path(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, const int&)':
src/src_client_main/internal_hbond_get_path.cpp:255: error: expected `,' or `...' before '&' token
src/src_client_main/internal_hbond_get_path.cpp:256: error: ISO C++ forbids declaration of `IntVect' with no type
src/src_client_main/internal_hbond_get_path.cpp: In member function `bool add_atoms_to_path(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, const int&)::PathRemover::operator()(int) const':
src/src_client_main/internal_hbond_get_path.cpp:258: error: `v' undeclared (first use this function)
src/src_client_main/internal_hbond_get_path.cpp:258: error: (Each undeclared identifier is reported only once for each function it appears in.)
src/src_client_main/internal_hbond_get_path.cpp: In function `std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > add_atoms_to_path(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, const int&)':
src/src_client_main/internal_hbond_get_path.cpp:347: error: no matching function for call to `remove_if(__gnu_cxx::__normal_iterator<std::vector<int, std::allocator<int> >*, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > >, __gnu_cxx::__normal_iterator<std::vector<int, std::allocator<int> >*, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > >, add_atoms_to_path(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, const int&)::PathRemover)'
With my line numbering,
Code:
struct PathRemover // 252
{ // 253
PathRemover(int val) : m_val(val) {} // 254
bool operator()(const IntVect& v) const // 255
{ // 256
// if m_val is in this vector, mark it to be removed // 257
return std::find(v.begin(), v.end(), m_val) != v.end(); // 258
} // 259
// 260
int m_val; // 261
}; // 262
new_set_of_paths.erase(std::remove_if(new_set_of_paths.begin(), // 345
new_set_of_paths.end(), // 346
PathRemover(current_neighbor)), // 347
new_set_of_paths.end()); // 348
It seems the issue is primarily with the v. vector in the struct.
LMHmedchem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|