Skip to content

Instantly share code, notes, and snippets.

@rchl
Created April 29, 2012 19:07
Show Gist options
  • Save rchl/2552756 to your computer and use it in GitHub Desktop.
Save rchl/2552756 to your computer and use it in GitHub Desktop.
template
#include <stdio.h>
extern void print1();
extern void print2();
int main()
{
printf("Two values printed below should be different?\n");
print1();
print2();
return 0;
}
#include <stdio.h>
template<typename T>
class SuperFoo
{
public:
void print_value(T& arg)
{
printf("Got value: %d\n", arg.value);
}
};
#include <stdio.h>
#include "tmpl.h"
typedef union TYPE
{
unsigned short value;
unsigned int integer;
} TYPE;
void print1()
{
TYPE t;
t.integer = -1;
SuperFoo<TYPE> impl;
impl.print_value(t);
}
#include <stdio.h>
#include "tmpl.h"
typedef union TYPE
{
unsigned int value;
} TYPE;
void print2()
{
TYPE t;
t.value = -1;
SuperFoo<TYPE> impl;
impl.print_value(t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment