A test by yourself, which will be useful for future reference.
Use union to associate long with two 32-bit int values in a struct. If map is passed, use long. The struct is used normally when the struct is retrieved, reduce the efficiency of map copy struct during massive data processing
# Include <iostream> <br/> # include <iterator> <br/> # include <string> <br/> # include <map> <br/> using namespace STD; <br/> typedef Union <br/> {<br/> long key; <br/> struct {<br/> int FD; <br/> int use_count; <br/>} FD; <br/>} aio_fd; <br/> int main (void) <br/>{< br/> cout <sizeof (aio_fd) <Endl; </P> <p> Map <string, long> fd_map; <br/> aio_fd temp_fd; <br/> temp_fd.fd.fd = 2; <br/> temp_fd.fd.use_count = 18; </P> <p> fd_map.insert (make_pair ("AA", temp_fd.key); <br/> Map <string, long> :: iterator fd_iter = fd_map.find (string ("AA"); </P> <p> aio_fd get_fd; <br/> get_fd.key = fd_iter-> second; </P> <p> cout <"FD:" <get_fd.fd.fd <"/tuse count:" <get_fd.fd.use_count <Endl; <br/> return 0; <br/>}