看板Programming
标 题Re: [问题] C++ Primer 3/e中文版
发信站政大狂狷年少 (Fri Mar 9 22:00:28 2007)
转信站ptt!ctu-reader!ctu-peer!news.nctu!netnews.csie.nctu!news.cs.nthu!WHSHS
※ 引述《[email protected] (傲天祥云)》之铭言:
> 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:
[email protected]
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"的狂狷不驯;属於年少的轻狂色彩 ◎