emplace
, allows an object to be constructed from the arguments passed into it without needing to create the object to be passed in first, saving an overhead by removing a copy construction which normally happens as the result of creating objects to be inserted.
You can achieve what you want by use of pointers
typedef boost::unordered::unordered_map<std::String, CLIENT_STATE* > CLIENT_MAP;
But using pointers might prove problematic for memory handling, like object deletion, etc.
You can consider using boost::shared_ptr
, something like following :
(I'm no shared_ptr/boost expert)
include <boost/shared_ptr.hpp>
boost::unordered::unordered_map<std::String,
boost::shared_ptr<CLIENT_STATE> > client_map ;
std::string s ="client1" ;
CLIENT_STATE *c1 = new CLIENT_STATE;
//c1->state, c1->id, etc
my_map[t] = c1 ;
If you needn't make copies of the objects stored in the map, you can use C++11's std::unique_ptr