Hi List,
i tried to replace the following code:
typedef vector<double>::iterator it;
for(it i = TMW.begin(); i != TMW.end(); ++i) {
sx += *i;
sxx += sqr(*i);
} // for it
with:
sx = accumulate(TMW.begin(), TMW.end(), 0.0);
sxx = accumulate(TMW.begin(), TMW.end(), 0.0, sqr);
sqr (same for both versions):
namespace hr_math {
template<class T>
inline T sqr(T x) { return x * x; }
}
sx and sxx are double.
If i compile it i get the error messages:
71 E:\dev\dev-c++\proj2\procabi.cpp
no matching function for call to `accumulate(
What is wrong with my code ? Similar code can be found in several books.
Thanks for your help
greetings
Horst
--
Horst Rößner
Postf. 1802
52205 Stolberg
ICQ ID #74808448
h.r...@gm...
h.g...@t-...
Werden Sie mit uns zum "OnlineStar 2002"! Jetzt GMX wählen -
und tolle Preise absahnen! http://www.onlinestar.de
|