Topic: Why does for_each in STL use function pointer as paramter?
Author: Enno Rehling <enno@uni-paderborn.de>
Date: 1997/01/16 Raw View
angelo wrote:
>
> As far as I know , all generic algrithms in STL take function objects
> as parameter except "for_each". Why? I think function objects are more
> powerful than function pointers, since you can pass some other
> paramters in the objects' constructors.
for_each, too takes a function onject - there's no such thing as passing
function pointers in the STL, as far as I know. You'd have a strange
implementation if this were so.
Enno
email: enno@uni-paderborn.de
WWW: http://pbhrzs0.uni-paderborn.de/~q09960/public/
phone: Int+ 49 5251-760796
smail: Kilianstr. 129a
33098 Paderborn / Germany
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: angelo@iii.org.tw (angelo)
Date: 1997/01/16 Raw View
As far as I know , all generic algrithms in STL take function objects
as parameter except "for_each". Why? I think function objects are more
powerful than function pointers, since you can pass some other
paramters in the objects' constructors.
=============================================================
Huang-Ming Huang <angelo@iii.org.tw>
Institute for Information Industry, Taipei, Taiwan, ROC
Tel: 886-2-564-3588 ext 202 ; Fax: 886-2-564-3775
==============================================================
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: angelo@iii.org.tw (angelo)
Date: 1997/01/17 Raw View
In article <32DE0593.3BFB@uni-paderborn.de>, enno@uni-paderborn.de says...
> angelo wrote:
> >
> > As far as I know , all generic algrithms in STL take function objects
> > as parameter except "for_each". Why? I think function objects are more
> > powerful than function pointers, since you can pass some other
> > paramters in the objects' constructors.
>
> for_each, too takes a function onject - there's no such thing as passing
> function pointers in the STL, as far as I know. You'd have a strange
> implementation if this were so.
>
> Enno
>
Thank you, I have the impression of "for_each" takes function pointer
is base on the example in "STL Tutorial and Refercence Guide" by
Musser without paying attentionto the declaration of for_each. Now
I learn that function can be passed as object in template class. A
big surprise.
=============================================================
Huang-Ming Huang <angelo@iii.org.tw>
Institute for Information Industry, Taipei, Taiwan, ROC
Tel: 886-2-564-3588 ext 202 ; Fax: 886-2-564-3775
==============================================================
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]