我被这个错误困住了:
从/cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/algorithm:62:0,到/cluster/compwa_externals/boost_1_55_0/include/boost/move/algorithm.hpp:23,的文件中包含的gcc.compile.c++ gcc.compile.c++从/cluster/compwa_externals/boost_1_55_0/include/boost/move/move.hpp:24,到/cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/util.hpp:19,从/cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/buckets.hpp:14,从/cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/table.hpp:10,到/cluster/compwa_externals/boost_1_55_0/include/boost/unordered/detail/equivalent.hpp:14,从/cluster/compwa_externals/boost_1_55_0/include/boost/unordered/unordered_set.hpp:17,从/cluster/compwa_externals/boost_1_55_0/include/boost/unordered_set.hpp:16,到/cluster/compwa_externals/boost_1_55_0/include/boost/graph/adjacency_list.hpp:21,从Physics/HelicityAmplitude/HelicityDecayTree.hpp:17,从Physics/HelicityAmplitude/HelicityDecayTree.cpp:12: /cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/bits/stl_algo.h:在“_RandomAccessIterator std::__find”( _RandomAccessIterator,_RandomAccessIterator,const _Tp&,std::random_access_iterator_tag)的实例化中使用_RandomAccessIterator= __gnu_cxx::__normal_iterator >;_Tp =HelicityFormalism::粒子克利尔状态: /cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/bits/stl_algo.h:4441:45:需要从‘_IIter std::find(_IIter,_IIter,const _Tp&)到_IIter= __gnu_cxx::__normal_iterato r >;_Tp =HelicityFormalism::ParticleState’从这里需要 /cvmfs/cluster/gcc/gcc-4.8.3/include/c++/4.8.3/bits/stl_algo.h:166:17:错误:与‘operator==’不匹配(操作数类型为‘HelicityFormalism::ParticleState’和‘const::ParticleState’) if (*__first == __val)
我看到他要求对ParticleState进行比较。不过,我真的不明白他为什么要这个比较。我的相关代码如下:
类的标题:
class HelicityDecayTree {
boost::adjacency_list<> decay_tree_;
std::vector<ParticleState> particles_;
public:
void createDecay(const ParticleState &mother,
const ParticleStatePair &daughters);
}以及该成员函数的来源:
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_);
}和ParticleState结构:
struct ParticleState {
int particle_id_;
std::string name_;
Spin J_;
Spin M_;
};他应该为两个const ParticleStates合成operator==,但出于某种原因,查找方法是要求一个非const版本的1参数.
提前决定,史蒂夫
发布于 2015-05-05 15:41:57
好吧,我忘了编译器不会合成operator==。所以我只是失踪了
bool operator==(const ParticleState &rhs) const {
...
}https://stackoverflow.com/questions/30056585
复制相似问题