Created
February 27, 2012 03:35
-
-
Save thefloweringash/1921139 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
template <typename T> struct lift { | |
typedef T t; | |
}; | |
template <typename T> struct ptr { | |
typedef typename lift<T>::t* t; | |
}; | |
template <typename T> struct lift<ptr<T> > { | |
typedef typename ptr<T>::t t; | |
}; | |
template <size_t sz, typename T> struct arrayn { | |
typedef typename lift<T>::t t[sz]; | |
}; | |
template <size_t sz, typename T> struct lift<arrayn<sz, T> > { | |
typedef typename arrayn<sz, T>::t t; | |
}; | |
template <typename T> struct array { | |
typedef typename lift<T>::t t[]; | |
}; | |
template <typename T> struct lift<array<T> > { | |
typedef typename array<T>::t t; | |
}; | |
int main() { | |
{ | |
int foo; | |
ptr<int>::t bar = &foo; | |
} | |
{ | |
int foo[7]; | |
ptr<arrayn<7, int> >::t bar = &foo; | |
} | |
{ | |
int (*foo)[]; | |
ptr<ptr<array<int> > >::t bar = &foo; | |
} | |
{ | |
int foo; | |
int *bar = &foo; | |
ptr<ptr<int> >::t baz = &bar; | |
} | |
{ | |
// cdecl> declare x as pointer to array 7 of pointer to function returning int; | |
int (*(*x)[7])() = NULL; | |
ptr<arrayn<7, int (*)()> >::t y = x; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment