1
我在編譯具有較新版本的gcc的系統上使用std :: lower_bound的代碼時遇到了一些麻煩。從我的測試中,4.1有效,但4.6失敗。沒有與較新的gcc調用'lower_bound'的匹配函數
下面是相關的代碼片段:
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&)
是否有人對如何解決這個想法?
你可以發佈一個簡短的自我包含的程序演示該問題? –