#include <iostream>
#include <stdexcept>

#include <boost/any.hpp>

class Committer
{
public:	

	template <typename T>
	void mark_var_change(T *var)
	{
	    mPointer = var;
	}

	template <typename T>
	void commit_change(T new_value)
	{
		T* pointer = boost::any_cast<T*>(mPointer); // throw with bad type
		if (pointer == nullptr) {
			throw std::runtime_error("nullptr was stocked");
		}
	    *pointer = new_value;
	}

private:
    boost::any mPointer;
};


int main() {
	Committer c;
	int i;
	float f;

	c.mark_var_change(&i);
	c.commit_change(42);
	
	c.mark_var_change(&f);
	c.commit_change(4.2f);
	
	std::cout << i << " " << f << std::endl;
}
