新しいバージョンの gcc を搭載したシステムで std::lower_bound を使用するコードをコンパイルする際に問題が発生しています。私のテストでは、4.1 は動作しますが、4.6 は失敗します。
関連するコード スニペットは次のとおりです。
template <typename RandomAccessIterator, typename Value, typename Comparer>
int my_binary_search(RandomAccessIterator const first, RandomAccessIterator const last, Value const& value, Comparer comparer)
{
RandomAccessIterator it(std::lower_bound(first, last, value, comparer));
//some more code below
}
私が見ているエラーは次のとおりです。
error: no matching function for call to ‘lower_bound(const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&, const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&, const int&, bool (*&)(int, int))’
testing.h:37:75: note: candidate is:
/usr/include/c++/4.6/bits/stl_algobase.h:936:5: note: template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)
これを修正する方法について誰かアイデアがありますか?