Heapless C++ polymorphism

/* EmbeddedCppDemo.cpp
 * Vincent Jordan
 * 2013.08.06          */

/* placement new */
#include <new>

typedef unsigned int size_t;

/* Max type size of variadic template
 * See: http://stackoverflow.com/a/13246426 */
template<typename Head>
constexpr size_t max_size() {
	return sizeof(Head);
}

template<typename Head, typename Next, typename... Tail>
constexpr size_t max_size() {
	return max_size<Head>() > max_size<Next, Tail...>() ? max_size<Head>() : max_size<Next, Tail...>();
}

/* Simple polymorphism */
class AbstractThing {
public:
	virtual void sideEffect(unsigned int&) = 0;
};

class ThingA : public AbstractThing {
public:
	virtual void sideEffect(unsigned int& i) {
		i = i + 1;
	}
};

class ThingB : public AbstractThing {
public:
	virtual void sideEffect(unsigned int& i) {
		i = i + 2;
	}
};

/* Generic container for placement new
 * Inspired from: http://www.barrgroup.com/Embedded-Systems/How-To/Polymorphism-No-Heap-Memory */
template<class Generic, typename... Containee>
class GenericContainer {
	char buffer[max_size<Containee...>()];
public:
	Generic* operator->() {
		return (Generic*)buffer;
	}
	Generic const* operator->() const {
		return  (Generic const*)buffer;
	}
	Generic* get() {
		/* for placement new or delete */
		return (Generic*)buffer;
	}
};

GenericContainer<AbstractThing, ThingA, ThingB> thingArray[2];

int main() {
	new(thingArray[0].get()) ThingA;
	new(thingArray[1].get()) ThingB;
	
	unsigned int a = 0;
	
	/* polymorphism magic here */
	for(int i=0; i<2; i++) {
		thingArray[i]->sideEffect(a);
	}
	
	return a;
}