2013-07-12 21 views
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&) 

是否有人對如何解決這個想法?

+0

你可以發佈一個簡短的自我包含的程序演示該問題? –

回答

1

對於任何人在谷歌發現這樣的: 我有同樣的問題 包括了「功能性」和「名單」,沒有給我任何錯誤LOWER_BOUND wasnt定義或任何東西,只是它無法找到一個匹配功能。

包括「算法」的伎倆..近了這樣的傻事搜索周圍的一個小時