[問題] ambiguous call to overloaded function
遇到一個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
請教各位
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.58.205
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1411014092.A.65A.html
※ 編輯: QQ29 (118.163.58.205), 09/18/2014 12:23:26
→
09/18 12:30, , 1F
09/18 12:30, 1F
→
09/18 12:30, , 2F
09/18 12:30, 2F
→
09/18 12:30, , 3F
09/18 12:30, 3F
→
09/18 15:42, , 4F
09/18 15:42, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章