#include <deque>
#include <memory>
#include <iostream>

template<class T> class manager {
	static void construct(T* p, const T& val) {
		new((void*)p) T(val); }
	template<class U, class... Args>
	  static void construct(U* p, Args&&... args) {
		new((void*)p) T(std::forward<Args>(args)...); }
	class allocator: public std::allocator<T> {
	public:
		void construct(T* p, const T& val) {
			manager::construct(p, val); }
		template<class U, class... Args>
		  void construct(U* p, Args&&... args) {
			  manager::construct(p, std::forward<Args>(args)...); }
	//needed for deque ...dunno why it is using rebind for T
		template<class U> struct rebind {
			typedef typename std::conditional<
			  std::is_same<T,U>::value, allocator,
			  std::allocator<U>>::type other; };
	};
	std::deque<T, allocator> storage; //deque preserves pointers
public:
	template<class... Args>
	  T* create(Args&&... args) {
		storage.emplace_back(std::forward<Args>(args)...);
		return &storage.back();
	}
};

class special {
	friend class manager<special>;
	int i;
	special(int i): i(i) {}
public:
	int get() const { return i; }
};

int main() {
	manager<special> m;
	special* p = m.create(123);
	std::cout << p->get() << std::endl;
}
