私は論文のために私の教授のための質量分析データベースに取り組んでいます。このサイトは非常に参考になっていますが、これも私の最初の投稿です。std :: lower_boundの奇妙なエラー
私はフラグでGNU CPP 4.8を使用して、次のエラーを取得しています:
この、その結果CXX = g++
BOOSTDIR = /home/user/boost_1_60_0/ #Uses boost_1_60_0 lirary.
CXXFLAGS = -std=c++11 -g -ggdb -rdynamic -D_GLIBCXX_DEBUG -Wall -Wextra -I$(BOOSTDIR)
LDFLAGS = -L/home/user/boost_1_60_0/stage/lib -lboost_system -lboost_filesystem -lboost_iostreams
:ここ
/usr/include/c++/4.8/bits/stl_algo.h:2438:error: elements in iterator range
[__first, __last) are not partitioned by the predicate __comp and value
__val.
Objects involved in the operation:
iterator "__first" @ 0x0x7ffd8a308c30 {
type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIP11cache_tableNSt9__cxx19986vectorIS3_SaIS3_EEEEENSt7__debug6vectorIS3_S7_EEEE (mutable iterator);
state = dereferenceable (start-of-sequence);
references sequence with type `NSt7__debug6vectorI11cache_tableSaIS1_EEE' @ 0x0x7ffd8a308c30
}
iterator "__last" @ 0x0x7ffd8a308c60 {
type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIP11cache_tableNSt9__cxx19986vectorIS3_SaIS3_EEEEENSt7__debug6vectorIS3_S7_EEEE (mutable iterator);
state = past-the-end;
references sequence with type `NSt7__debug6vectorI11cache_tableSaIS1_EEE' @ 0x0x7ffd8a308c60
}
Aborted (core dumped)
は、関連するメソッド呼び出しです:
void db::get_range(double mz_min, double mz_max, double rt_min, double rt_max, std::vector<dp> & ilist){
//Get valid rt ranges. //OPTIMIZE
auto rt_low = std::lower_bound(tlist.begin(), tlist.end(), rt_min, rt_less_than());
//Iterate from low end until out of range or end of list.
for(auto a = rt_low; (a != tlist.end() && (*(*a).begin()).rt_max < rt_max); a++){
//Get valid mz ranges. //OPTIMIZE
auto mz_low = std::lower_bound((*a).begin(), (*a).end(), mz_min, mz_less_than()); //This call is what is throwing the error.
for(auto b = mz_low; (b != (*a).end() && (*(*a).rbegin()).mz_max < mz_max); b++){
std::clock_t access_time = std::clock();
(*b).get(mz_min, mz_max, rt_min, rt_max, ilist, access_time);
tqueue.push(std::make_pair(&(*b), access_time));
trim();
}
}
}
サポートコードの一部は次のとおりです。
//Comparator to check rt ranges.
struct rt_less_than{
bool operator()(std::vector<cache_table> & p, double s) const{
return p[0].rt_max < s;
}
bool operator()(double p, std::vector<cache_table> & s) const{
return p < s[0].rt_max;
}
};
//Comparator to check mz ranges.
struct mz_less_than{
bool operator()(cache_table & p, double s) const{
return p.mz_max < s;
}
bool operator()(double p, cache_table & s) const{
return p < s.mz_max;
}
};
このコード全体をリファクタリングするまで、この全体が機能していました。私はcppで最も経験が豊富ではなく、このエラーは関数のテンプレート要件を満たしていないのと同じように聞こえますが、mz_lower_than()オブジェクト内のクラス名を調べるとうまくいくようです。 mz_lower_than()の呼び出しの中でチェックすると、このテストセットのサイズが99のベクトルで約90回コールした後にエラーが発生することがわかりました。
このエラーを検出すると、他のいくつかがそれを見ていることがわかりましたが、最初の3ページの後には本当に答えがないようです。非常に単純な何かによって引き起こされたエキゾチックなエラーを感じるが、私はそれが何であるかを理解できないようだ。
プログラムが非常に大きいので、何が起こっているのかを理解するために必要な最小限のコードだけを貼り付けました。私はもちろん、必要に応じてさらにコードを貼り付けることができます。
誰でも私を助けることができますか? ありがとう!
これは、 'std :: lower_bound'が要求する厳密な弱い順番ではないようです。 –
[MCVE]を提示してください。 MCVEは単に「最小」ではなく、「完全」でもあります。あなたがまだそれを持っていない場合、あなたはまだデバッグを完了していません!サムはおそらくそうだろう。それらのコンパレータは私には疑いがあります。 –
コメントありがとう。私はstd :: sort()でエラーをチェックすることにします。 – mWellington