Doge Indirection

Started by
7 comments, last by Sik_the_hedgehog 9 years ago
Hackers have been around for too long, usually associated with dark themes and “the evil side” they represent the minority of IT Gurus that just have too much time on their hands, and a touch of evilness. Usually represented with a skull or “horrifically” they are iconic in a never ending battle against internet crime.
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
"I would try to find halo source code by bungie best fps engine ever created, u see why call of duty loses speed due to its detail." -- GettingNifty
Advertisement
megafp2.png

e31.jpg

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

At first, I was like, are you serious?

Then I actually read your code snip.

Now I'm like...

iseewhatyoudidthere_zpstgwbftuv.jpg

My reaction:

"Wait... that..."

".... oh good lord."
I know this was a joke, but if that it what is required to keep hackers out of my app, screw it! They can have their way with it for all I care!
unsee.jpg

I detect high levels of entertainment in this thread.

"Smoke me a kipper i'll be back for breakfast." -- iOS: Science Fiction Quiz

Reminds me of this (it's westley in the IOCCC list).

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

This topic is closed to new replies.

Advertisement