2001

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                          FILE: january.cpp */
/*                                                                            */
/*  From Hello.begin() to World.end() with the STL                            */
/*  ==============================================                            */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.00   17-JAN-2001   P. Tellenbach   http://www.heimetli.ch/             */
/*                                                                            */
/******************************************************************************/

#include <iostream>
#include <algorithm>

class oi : public std::ostream_iterator<char>
{
 public:
   oi( ostream_type &os ) : std::ostream_iterator<char>( os )
   {
   }

 template< typename V >
   int operator ()( V value )
   {
      return !value ;
   }
} ;

int main( )
{
   std::string  Hello = "Hello World !\n" ;
   std::string &World =  Hello ;

   return std::copy( Hello.begin(), World.end(), oi(std::cout) )( 42 ) ;
}