/******************************************************************************/ /* */ /* FILE: march.cpp */ /* */ /* Written while trying to understand "Modern C++ Design" */ /* ====================================================== */ /* */ /* Compiled and tested with GNU g++ V2.96 */ /* */ /* V1.00 31-MAR-2003 P. Tellenbach http://www.heimetli.ch/ */ /* */ /******************************************************************************/ #include <iostream> #define CLASS( c ) struct c { c() { std::cout << #c ; } } CLASS( H ) ; CLASS( e ) ; CLASS( l ) ; CLASS( o ) ; CLASS( w ) ; CLASS( r ) ; CLASS( d ) ; struct sp { sp() { std::cout << ' ' ; } } ; struct excl { excl() { std::cout << '!' ; } } ; struct nl { nl() { std::cout << '\n' ; } } ; class NullType { } ; template< class H, class T > struct TypeList { typedef H Head ; typedef T Tail ; } ; template< class X > struct Instantiate ; template<> struct Instantiate< NullType > { } ; template< class H, class T > struct Instantiate< TypeList< H, T > > { H head ; Instantiate<T> tail ; } ; int main() { Instantiate< TypeList< H, TypeList< e, TypeList< l, TypeList< l, TypeList< o, TypeList< sp, TypeList< w, TypeList< o, TypeList< r, TypeList< l, TypeList< d, TypeList< sp, TypeList< excl, TypeList< nl, NullType > > > > > > > > > > > > > > > instance ; return 0 ; }
Update 31. March 2023
This program compiles and runs without any changes.