#include <iostream>
#include <string>
#include <map>

class ValueHolder
{
	public:
		int **put(const std::string &key)
		{
			//throw if key exists
			auto val = values.emplace(key, nullptr);
			return &val.first->second;
		}
		void init()
		{
			for (auto &it: values)
				it.second = new int(10);
		}
		void print()
		{
			for (auto &it: values)
				std::cout<<*it.second<<std::endl;
		}
	private:
		std::map<std::string, int *> values;
};


int main() 
{
	ValueHolder holder;
	int **ptr = holder.put("Test");
	std::cout<<"ptr == nullptr: "<< (*ptr == nullptr)<<std::endl;
	
	holder.init();
	std::cout<<"ptr == nullptr: "<< (*ptr == nullptr)<<std::endl;
	std::cout<<**ptr<<std::endl;
	
	**ptr = 100;
	holder.print();
	
	return 0;
}