MGVTBL* get_object_vtbl(const std::type_info& pre_key, int (*destruct_ptr)(pTHX_ SV*, MAGIC*)) { static boost::ptr_map<const std::type_info*, MGVTBL> table; const std::type_info* key = &pre_key; if (table.find(key) == table.end()) { const MGVTBL tmp = {0, 0, 0, 0, destruct_ptr MAGIC_TAIL}; table.insert(key, new MGVTBL(tmp)); } return &table[key]; }
void insertOrReplace( boost::ptr_map<std::string, Geometry >& map, std::string key, Geometry* value ) { boost::ptr_map<std::string, Geometry >::iterator found = map.find( key ); if ( found != map.end() ) { map.erase( found ); } map.insert( key, value ); }