对';下限';使用较新的gcc

对';下限';使用较新的gcc,gcc,version,binary-search,lower-bound,Gcc,Version,Binary Search,Lower Bound,在使用较新版本的gcc的系统上编译使用std::lower_bound的代码时遇到一些问题。根据我的测试,4.1可以工作,但是4.6失败了 以下是相关的代码片段: template <typename RandomAccessIterator, typename Value, typename Comparer> int my_binary_search(RandomAccessIterator const first, RandomAccessIterator const la

在使用较新版本的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
}
模板
int my_binary_搜索(RandomAccessIterator const first,RandomAccessIterator const last,Value const&Value,Comparer-Comparer)
{
RandomAccessIterator(std::lower_bound(first、last、value、comparer));
//下面还有一些代码
}
我看到的错误是:

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&)
错误:调用“下限(const\uu gnu\u cxx::\uu normal\u迭代器&,const\uu gnu cxx::\uu normal\u迭代器&,const int&,bool(*&)(int,int))”时没有匹配的函数
测试。h:37:75:注:候选人为:
/usr/include/c++/4.6/bits/stl_algobase.h:936:5:注意:模板_forwarditeratorstd::lower_bound(_ForwardIterator,_ForwardIterator,const _Tp&)

有人知道如何解决这个问题吗?

对于在谷歌上找到这个问题的人: 我也有同样的问题 包括“函数”和“列表”,没有给我任何错误,下限没有定义或什么,只是它找不到匹配的函数


包括“算法”就成功了。。你能发布一个简短的自足程序来演示这个问题吗?我也有一个类似的问题,这对我来说也很有效。我发誓我的代码前一段时间还有效,但后来突然不行了#他成功了。奇怪的