19 lines
		
	
	
		
			538 B
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			19 lines
		
	
	
		
			538 B
		
	
	
	
		
			C
		
	
	
	
	
	
|  | #pragma once
 | ||
|  | #include "olcPixelGameEngine.h"
 | ||
|  | 
 | ||
|  | //A class that has an initialization lock so that when the lock is activated, any further gets that are missing items in it will report themselves for easier debugging detection.
 | ||
|  | template<typename T,typename O> | ||
|  | class safemap{ | ||
|  | 	std::map<T,O>map; | ||
|  | 	bool initialized=false; | ||
|  | public: | ||
|  | 	O&operator[](T key){ | ||
|  | 		if(initialized&&map.count(key)==0){ | ||
|  | 			std::cout<<"WARNING! Trying to get non-existent key "<<key<<"!"<<std::endl; | ||
|  | 		} | ||
|  | 		return map[key]; | ||
|  | 	} | ||
|  | 	void SetInitialized(){ | ||
|  | 		initialized=true; | ||
|  | 	} | ||
|  | }; |