/******************************************************************************/
/* */
/* FILE: march.cpp */
/* */
/* In case you can't see it: I just pass cout.put to for_each ... */
/* ============================================================== */
/* */
/* Compiled and tested with Visual C++ V6.0 */
/* */
/* V1.00 25-MAR-2001 P. Tellenbach http://www.heimetli.ch/ */
/* */
/******************************************************************************/
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
int main()
{
string str = "Hello World !\n" ;
for_each( str.begin(), str.end(),
bind1st( mem_fun1_t< basic_ostream<char>&, basic_ostream<char>, char >(cout.put), &cout )
) ;
return 0 ;
}
Update 21. March 2021
The compiler complained about cout.put. Replacing cout. with ostream:: resolved the issue.
/******************************************************************************/
/* */
/* FILE: march.cpp */
/* */
/* In case you can't see it: I just pass cout.put to for_each ... */
/* ============================================================== */
/* */
/* Compiled and tested with Visual C++ V6.0 */
/* */
/* V1.00 25-MAR-2001 P. Tellenbach https://www.heimetli.ch/ */
/* */
/* Compiled and tested with g++ V10.2.1 */
/* */
/* V2.00 21-MAR-2021 P. Tellenbach https://www.heimetli.ch/ */
/* */
/******************************************************************************/
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
int main()
{
string str = "Hello World !\n" ;
for_each( str.begin(), str.end(),
bind1st( mem_fun1_t< basic_ostream, char >(&ostream::put), &cout )
) ;
return 0 ;
}