Skip to content

Instantly share code, notes, and snippets.

@o11c
Created September 24, 2013 19:30
Show Gist options
  • Select an option

  • Save o11c/6690046 to your computer and use it in GitHub Desktop.

Select an option

Save o11c/6690046 to your computer and use it in GitHub Desktop.
#include <cstdio>
template<class T>
class Pointer
{
T *v;
public:
Pointer(T *t) : v(t) {}
__attribute__((used))
T *operator ->()
{
return v;
}
__attribute__((used))
T& operator *()
{
return *v;
}
};
__attribute__((noinline))
void test(Pointer<char *> p)
{
puts(*p);
}
int main(int argc, char **argv)
{
test(argv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment