Re: [問題] C++ Primer 3/e中文版
※ 引述《linbaskenny.bbs@ptt.cc (傲天祥雲)》之銘言:
> P.591
> int ires;
> string sval1;
> vector<string> svec;
> //...
> ires = count_if(svec.begin(), svec.end(), equal_to<string>(), sval1);
> 但SGI的版本是
> template <class InputIterator, class Predicate>
> iterator_traits<InputIterator>::difference_type
> count_if(InputIterator first, InputIterator last, Predicate pred);
> template <class InputIterator, class Predicate, class Size>
> void count_if(InputIterator first, InputIterator last,
> Predicate pred,
> Size& n);
> 第四個參數型別也不一樣
> 而具我所查到的資料
> ires = count_if(svec.begin(), svec.end(), bind2nd(equal_to<string>(), sval1));
> 請高手解答疑惑@@
看不出來你想問的東西是什麼,
你不是已經查到正確的改法了嗎?
count_if 這個部分其實是英文版的錯誤,
中文版的譯者也有把堪誤寫在網站上,
總之就是你包個 bind2nd() 在外面就可以了啊。
--
Name: Tseng, Ling-hua E-mail Address: uranus@it.muds.net
School: National Tsing Hua University Department: Computer Science
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage: https://it.muds.net/~uranus
--
╔═══╗ ┼────────────────────────╮
║狂狷 ║ │* Origin:[ 狂 狷 年 少 ] whshs.cs.nccu.edu.tw ╰─╮
║ 年少║ ┼╮ < IP:140.119.164.252 > ╰─╮
╚╦═╦╝ ╰ * From:61-230-221-34.dynamic.hinet.net
─╨─╨─ KGBBS ─ ◎ 遨翔"BBS"的狂狷不馴;屬於年少的輕狂色彩 ◎
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章