作者:
QQ29 (我愛阿蓉)
2014-09-18 12:21:29遇到一個compile error
但我看不出來錯的原因是什麼
我寫一個partition function例如
template<typename Iterator, class Predicate>
Iterator partition(Iterator begin, Iterator end, Predicate pred)
{
return begin;
}
然後
#include <algorithm>
int main()
{
std::vector<int> vec;
partition(vec.begin(), vec.end(), [](int i){return true; });
}
compile error 就說 partition 這function ambiguous了
不解的是
algorithm裡面的partition包在namespace std底下 跟我這有啥關係
我也確定我沒自己寫using namespace std;
而若我改成::partition(....); 就沒問題了
或是拔掉algorithm 也可以compile 過, 但我會用到algorithm的其他method 所以不能拔
我是用VC
而我請朋友在GCC驗證 也說會error
請教各位
謝謝