I'm stuck at this error:
gcc.compile.c++ Physics/HelicityAmplitude/bin/gcc-4.8.3/debug/HelicityDecayTree.o In file included from /cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/algorithm:62:0, from /cluster/compwa_externals/boost_1_55_0/include/boost/move/algorithm.hpp:23, from /cluster/compwa_externals/boost_1_55_0/include/boost/move/move.hpp:24, from /cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/util.hpp:19, from /cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/buckets.hpp:14, from /cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/table.hpp:10, from /cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/equivalent.hpp:14, from /cluster/compwa_externals/boost_1_55_0/include/boost/unordered/unordered_set.hpp:17, from /cluster/compwa_externals/boost_1_55_0/include/boost/unordered_set.hpp:16, from /cluster/compwa_externals/boost_1_55_0/include/boost/graph/adjacency_list.hpp:21, from Physics/HelicityAmplitude/HelicityDecayTree.hpp:17, from Physics/HelicityAmplitude/HelicityDecayTree.cpp:12:
/cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__find(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator >; _Tp = HelicityFormalism::ParticleState]':
/cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/bits/stl_algo.h:4441:45: required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterato r >; _Tp = HelicityFormalism::ParticleState]' Physics/HelicityAmplitude/HelicityDecayTree.cpp:59:61: required from here
/cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/bits/stl_algo.h:166:17: error: no match for 'operator==' (operand types are 'HelicityFormalism::ParticleState' and 'const Helicit yFormalism::ParticleState') if (*__first == __val)
I see that he is asking for a const to non-const comparison of ParticleState. However I don't really understand why he is asking for this comparison. My relevant code is the following:
The header for the class:
class HelicityDecayTree {
boost::adjacency_list<> decay_tree_;
std::vector<ParticleState> particles_;
public:
void createDecay(const ParticleState &mother,
const ParticleStatePair &daughters);
}
And the source for that member function:
void HelicityDecayTree::createDecay(const ParticleState &mother,
const ParticleStatePair &daughters) {
// add particles to the list
unsigned int mother_vector_index;
unsigned int daughter1_vector_index;
unsigned int daughter2_vector_index;
if (std::find(particles_.begin(), particles_.end(), mother)
== particles_.end()) {
mother_vector_index = particles_.size();
particles_.push_back(mother);
}
else {
mother_vector_index = std::distance(particles_.begin(),
std::find(particles_.begin(), particles_.end(), mother));
}
if (std::find(particles_.begin(), particles_.end(), daughters.first)
== particles_.end()) {
daughter1_vector_index = particles_.size();
particles_.push_back(daughters.first);
}
else {
daughter1_vector_index = std::distance(particles_.begin(),
std::find(particles_.begin(), particles_.end(), daughters.first));
}
if (std::find(particles_.begin(), particles_.end(), daughters.second)
== particles_.end()) {
daughter2_vector_index = particles_.size();
particles_.push_back(daughters.second);
}
else {
daughter2_vector_index = std::distance(particles_.begin(),
std::find(particles_.begin(), particles_.end(), daughters.second));
}
// then make the correct inserts into the vector and link appropriately
boost::add_edge(mother_vector_index, daughter1_vector_index, decay_tree_);
boost::add_edge(mother_vector_index, daughter2_vector_index, decay_tree_);
}
And the ParticleState struct:
struct ParticleState {
int particle_id_;
std::string name_;
Spin J_;
Spin M_;
};
Afaiu he should be synthesizing the operator== for two const ParticleStates, but for some reason the find method is asking for a non-const version for 1 argument...
Thx in advance, Steve
Ok I forgot that the compiler will not synthesize the operator==. So I was just missing
bool operator==(const ParticleState &rhs) const {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.