Update 2024-03-27: Greatly expanded the "Samples" page and renamed it to "Glossary".
Update 2024-04-04: Added 5 million mid-2011 posts from the k47 post dump. Browse (mostly) them here.
Update 2024-04-07: Added ~400 October 2003 posts from 4chan.net. Browse them here.

Welcome to Oldfriend Archive, the official 4chan archive of the NSA. Hosting ~170M text-only 2003-2014 4chan posts (mostly 2006-2008).
[29 / 0 / ?]

[1105741677] I was bored

No.287 View ViewReplyOriginalReport
...so I wrote something that I won't understand five bits of in 5 years.
See if you can understand what it does without compiling it. It's valid C++, except for the __int64 type, which is Microsoft-specific (replace with whatever your compiler uses).

Have fun.

#include <iostream>
using namespace std;
typedef __int64 pszint; /* FOR 64-BIT POINTERS */
typedef unsigned __int64 uint64;
typedef const char* charptr;

template<typename T> inline void For( T val, const T& end, T (*inc)( const T& ), void (*proc)( const T& ) ) { if( val < end ) { proc( val ); For( inc( val ), end, inc, proc ); } }
template<typename T> inline T If( bool cond, T (*proc)(), T (*eproc)() ) { return ( cond ? proc() : eproc() ); }
template<typename T, typename Q> inline Q Comp( T (*one)(), Q (*two)( const T& ) ) { return two( one() ); }
//template<typename T> inline pszint TypeId() { static T tag; return (pszint) &tag; }

void NullProc() {}
int IncrementInt( const int& i ) { return i + 1; }
uint64 GetValue() { return 36762444129608; /* BIG-ENDIAN */ }
charptr ToString( const uint64& str ) { static uint64 temp; temp = str; return (charptr) &temp; }
charptr GetString() { return Comp<uint64, charptr>( GetValue, ToString ); }
void PrintAndPause( const charptr& str ) { cout << str; getchar(); }
void InnerProc() { Comp<charptr, void>( GetString, PrintAndPause ); }
void Body( const int &i ) { If<void>( i <= 5, InnerProc, NullProc ); }
int main() { For<int>( 1, 10, IncrementInt, Body ); }