juli (caladri) wrote in dailysrc,
juli
caladri
dailysrc

Fun with recursion and the C++ type system and templates and and and. Get it?

#include <iostream>

template<typename T>
void f(T *x) {
        std::cout << __PRETTY_FUNCTION__ << ": " << x << std::endl;
        f(*x);
};

template<typename T>
void f(T& x) {
        std::cout << __PRETTY_FUNCTION__ << ": " << x << std::endl;
        f(&x);
};

static int y = 0;
static int *yp = &y;
static int **ypp = &yp;

int main(void) {
        f(ypp);
        return (0);
}

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 0 comments