#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <iterator>
#include <vector>
template < typename STREAM_TYPE, STREAM_TYPE& stm >
struct basic_vstream
{
template < typename T >
static STREAM_TYPE& print_any( const T& v) { return stm << v; }
static STREAM_TYPE& print_any( const basic_vstream& ) { return stm; }
template < typename FIRST, typename ... REST >
static STREAM_TYPE& print_any( const FIRST& first, const REST& ... rest )
{
const std:: size_t n = sizeof ...( rest) + 1 ;
if ( std:: rand ( ) % n == 0 ) return stm << first;
else return print_any( rest...) ;
}
template < typename ... ARGS >
const basic_vstream& operator( ) ( const ARGS& ... args ) const
{
print_any( args...) ;
return * this ;
}
// etc
const basic_vstream& operator( ) ( STREAM_TYPE& ( * manip) ( STREAM_TYPE& ) ) const
{
stm << manip; return * this ;
}
// other manipulators
} ;
using vstream = basic_vstream< std:: ostream , std:: cout > ;
using wvstream = basic_vstream< std:: wostream , std:: wcout > ;
const vstream vout;
const wvstream wvout;
int main( )
{
std:: srand ( std:: time ( nullptr) ) ;
const char space = ' ' ;
for ( int i = 0 ; i < 10 ; ++ i)
vout( "Attention!" , "Hear this!" , "Alert!" ) ( space) ( "We must leave!" , "We're out of money!" ) ( '.' ) ( std:: endl ) ;
std:: cout << '\n ' ;
for ( int i = 0 ; i < 10 ; ++ i)
{
vout( "Attention!" , "Hear this!" , "Alert!" ) ( space)
( "We must leave!" , "We're out of money!" ,
vout( "I hate" , "We detest" , "I loathe" ) ( space)
( "you" , "them" , "these guys" , "those people" ) ( '.' , '!' ) ) ( std:: endl ) ;
}
std:: cin .get ( ) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGN0aW1lPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDx2ZWN0b3I+Cgp0ZW1wbGF0ZSA8IHR5cGVuYW1lIFNUUkVBTV9UWVBFLCBTVFJFQU1fVFlQRSYgc3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