Reputation: 153
This is the problematic function:
void Molecule::initSimilarity(int depth)
{
int m = 1;
for (int j = 0; j < depth ; j++)
for (int i = 0 ; i < _size ; i++) //for any atom A
if (!getSetMask( //put all atoms which are equivalnt but not similar to A in their own
//equivalence class
[&](const Atom& b)->bool {return (_atoms[i]->_class == b._class) && !(isSimilar(*_atoms[i],b));},
[&m](Atom& b){b._class = m;} //113
).none()) m++; //114
}
And the output:
In file included from /usr/include/c++/4.5/memory:82:0,
from /usr/include/boost/dynamic_bitset_fwd.hpp:15, from /usr/include/boost/dynamic_bitset/dynamic_bitset.hpp:36, from /usr/include/boost/dynamic_bitset.hpp:15, from DataStructures/Molecule.h:21, from DataStructures/Molecule.cpp:8:
/usr/include/c++/4.5/functional: In static member function ‘static void std::_Function_handler::_M_invoke(const std::_Any_data&, _ArgTypes ...) [with _Functor = Molecule::initSimilarity(int)::, _ArgTypes = {Atom}]’:
/usr/include/c++/4.5/functional:2103:6: instantiated from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor, typename std::enable_if<(! std::is_integral<_Functor>::value), std::function<_Res(_ArgTypes ...)>::_Useless>::type) [with _Functor = Molecule::initSimilarity(int)::, _Res = void, _ArgTypes = {Atom}, typename std::enable_if<(! std::is_integral<_Functor>::value), std::function<_Res(_ArgTypes ...)>::_Useless>::type = std::function::_Useless]’
DataStructures/Molecule.cpp:114:5:
instantiated from here/usr/include/c++/4.5/functional:1713:9: error: no match for call to
‘(Molecule::initSimilarity(int)::) (Atom)’
DataStructures/Molecule.cpp:113:17: note: candidate is: Molecule::initSimilarity(int)::
I have no idea how this happens and what exactly that means, and I couldn't find any help on Google either...
The called function (isSimilar()):
bool Molecule::isSimilar(const Atom &A, const Atom &B)
{
AtomSet S;
for (int i = 0; i < _size; i++)
{
if (!_adjecancy[A._index][i]) continue; //Skip any atoms which aren't adjecant to A
int K = findAtom([&](const Atom& b){return (_adjecancy[B._index][b._index]) && (B._class == b._class) && (!S[B._index]);});
if (K == -1) return false;
S.flip(K);
}
return true;
}
and the one called from it:
int Molecule::findAtom(std::function<bool (const Atom)> property, std::function<void (Atom)> action = NULL)
{
for (int i=0 ; i<_size ; i++)
{
if (property(*_atoms[i]))
{
if (action != NULL) action(*_atoms[i]);
return i;
}
}
return -1;
}
used typedefs:
typedef dynamic_bitset<> AtomSet;
typedef dynamic_bitset<>::size_type atom_ind;
and of course, the function which stars in the error output:
AtomSet Molecule::getSetMask(std::function<bool (const Atom)> property, std::function<void (Atom)> action = NULL)
{
dynamic_bitset<> ret(_size);
if (property != NULL) for(int i=0; i<_size ; i++) ret.set(i, property(*_atoms[i]));
return ret;
}
Upvotes: 2
Views: 2962
Reputation: 283921
I see references in the argument type of the lambda, and no references in the functor types needed by getSetMask
.
Does your error persist if you make those consistent?
i.e. if you want action to modify the Atom
, you need
std::function<void (Atom&)> action
Upvotes: 1