#include <iostream>
#include <map>
using namespace std;

template<typename T>
struct ValueProxy
{
	ValueProxy(T& v)
		: value(v)
	{
	}
	
	operator T&()
	{
		return value;
	}
	
	operator const T&() const
	{
		return value;
	}
	
	ValueProxy& operator=(const T& nv)
	{
		value = nv;
		return *this;
	}
	
	T& value;
};

template<typename Key, typename Value>
struct SomeMap
{
	// Helpers
	using parent_t = std::map<Key, Value>;
	parent_t holder;
	
	// Part of interest
	ValueProxy<Value> operator[](const Key& key)
	{
		return {holder[key]};
	}
};

void modify(int& a) {// базовый метод
    a += 5;
}

void dump(const SomeMap<int,int> &mp)
{
	for (auto v : mp.holder)
	{
		cout << std::get<1>(v) << ' ';
	}
	cout << endl;
}

int main() 
{
	SomeMap<int, int> mp;
	
	// Proxy test 1
	mp[2] = 100;
	dump(mp);
	
	// Proxy test 2
	modify(mp[2]);
	dump(mp);
	
	// Proxt test 3
	mp[2] = mp[2] + 100;
	dump(mp);
	
	
	
	return 0;
}
