c++ - ptr_map inserting -


I have some predefined types that promote: noncopyable (so I have to store the pointer on these objects) Strong> boost: ptr_map as I know, the second argument in it already is an indicator, therefore, code:

  ptr_map  

Error:

Error: To call 'boost :: ptr_map & lt; Std :: basic_string & lt; Char & gt; Promotion :: Any & gt; :: insert (const char [11], boost :: any & amp;;)


UPD : when I do not pass any any refresh = any (new KeyEvent ()) indicator;

I am getting:

Error: To promote no match for calls: <: code>

P>

This version of takes the key from non-conferencing context, which means that you can not temporarily use any form first value is to prevent memory leaks;

You will leak in your code, temporary if the string maker was to throw it.

You must create a key object before creating a raw pointer:

  string key ("something"); Any * temp = whatever new; SomeMap.insert (key, temporary); To use  

or auto_ptr to ensure that whatever the object is removed has been removed:

 < Code> auto_ptr & lt; Any & gt; Temporary (whatever new); SomeMap.insert ("Something", Temporary);  

Comments