Advertisement
Guest User

Template Meta Programming

a guest
Mar 27th, 2010
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. template < size_t N > struct Q {
  7.   ostream & operator()() { return Q<(N>>6)>()() << ((char)(30+N%64)); }
  8. };
  9. template < > struct Q<0> { ostream & operator()() { return cout;} };
  10.  
  11. template <class H, class T> struct P { };
  12. typedef P< Q<0x29c71a6e>,
  13.   P< Q<0x270a8c74>,
  14.   P< Q<0x2da7bf2>,
  15.   P< Q<0x2e8f69c2>,
  16.   P< Q<0x2f9f68c2>,
  17.   P< Q<0x32d31a74>,
  18.   P< Q<0x23befaf0>, Q<0x29082082> >
  19.   > > > > >
  20. > M;
  21.  
  22. template < class H > struct V { void operator()() { H()(); } };
  23. template < class H, class T > struct V<P<H, T> >{ void operator()() { H()(); V<T>()(); }; };
  24.  
  25. int main() {
  26.     V<M>()();
  27.     cout << '\n';
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement