For this reason, I encourage all of us to start utilising the technique of indirection for storing all primitive datatypes in our programs. Not only will this make it impossible for hackers to track our variables, it will also allow us programmers to taste the sweet taste of having stopped said hackers with a doge meme.
#include <iostream>
template <class T, int N>
struct Indirection
{
typedef typename Indirection<T, N-1>::type* type;
typedef typename Indirection<T, N-1>::type child_type;
static void init(type& p)
{
p = new child_type;
Indirection<T, N-1>::init(*p);
}
static void cleanup(type& p)
{
Indirection<T, N-1>::cleanup(*p);
delete p;
}
};
template <class T>
struct Indirection<T, 0>
{
typedef T type;
static void init(type& p) {}
static void cleanup(type& p) {}
};
int main()
{
/* there happen to be 272 stars in the doge below */
Indirection<int, 272>::type cpu_cache_will_enjoy_this;
Indirection<int, 272>::init(cpu_cache_will_enjoy_this);
/*
* set the value of our variable using the power of the shibe
*/
* *
* * ** * * * **** * *
* * ** * * * * * * *
*** ******** * * * * * * *
*** * ** * * * * * * * * *
** **** * * * * * * * * * * *
* ** ** * * * **** * *
* *** **** * *
* **** ***
* **** *
* ******** * *
* **** ** * * ** *
* **** * * * *
* *** * ** * * ** * **
* * * * * * * ** *
** * * ** ** ** * *
** **** **
********** *** * * * * *
** * ***
* * ** ** * * *** ** ** * * ** * **
* * * * ** * * * ** * * * * * * *
* * * ** * * * ** ** * * ** * *
cpu_cache_will_enjoy_this = 20;
/*
* now output the value to stdout
*/
std::cout << " the value is: " << ****************************************** // make absolutely sure not to go over the 80 character per line limit, as to not enrage The Powers That Be (Linus Torvalds) in the mailing list
****************************************************************************
****************************************************************************
********************* ******************************************************
***cpu_cache_will_enjoy_this << std::endl;
/*
* clean up like good programmers - no memory leaks, check it with valgraind
* if you don't believe
*/
Indirection<int, 272>::cleanup(cpu_cache_will_enjoy_this);
return 0;
}
Granted, the error messages can become a little bit confusing, but all you have to do is write a batch script to parse the error output in order to understand how many stars you forgot:/home/thecomet/documents/programming/test/main.cpp: In function ‘int main()’:
/home/thecomet/documents/programming/test/main.cpp:81:61: error: no matching function for call to ‘Indirection<int, 273>::cleanup(Indirection<int, 0>::type********************************************************************************************************************************************************************************************************************************************************************************&)’
Indirection<int, 273>::cleanup(cpu_cache_will_enjoy_this);
^
/home/thecomet/documents/programming/test/main.cpp:81:61: note: candidate is:
/home/thecomet/documents/programming/test/main.cpp:15:17: note: static void Indirection<T, N>::cleanup(typename Indirection<T, (N - 1)>::type*&) [with T = int; int N = 273; Indirection<T, N>::type = int*********************************************************************************************************************************************************************************************************************************************************************************; typename Indirection<T, (N - 1)>::type = int********************************************************************************************************************************************************************************************************************************************************************************]
static void cleanup(type& p)
^
/home/thecomet/documents/programming/test/main.cpp:15:17: note: no known conversion for argument 1 from ‘Indirection<int, 272>::type {aka int********************************************************************************************************************************************************************************************************************************************************************************}’ to ‘Indirection<int, 0>::type*********************************************************************************************************************************************************************************************************************************************************************************& {aka int*********************************************************************************************************************************************************************************************************************************************************************************&}’
CMakeFiles/indirection.dir/build.make:54: recipe for target 'CMakeFiles/indirection.dir/main.cpp.o' failed