To map integers to doubles, use this:
db_map<int, double, ElementHolder<double> >;
To store a char*
string with long
keys, use this:
Use this for const char*
strings:
To map one const string to another, use this type:
db_map<const char*, const char*, ElementHolder<const char*> >;
For and wchar_t*
strings, _DB_STL_StoreElement()
must be called following partial or total modifications before iterator movement, container::operator[]
or iterator::operator*/->
calls. Without the _DB_STL_StoreElement()
call, the modified change will be lost. If storing an new value like this:
*iterator = new_char_star_string;
the call to _DB_STL_StoreElement()
is not needed.
Note that passing a NULL pointer to a container of char*
type or passing a std::string
with no contents at all will insert an empty string of zero length into the database.
The string returned from a container will not live beyond the next iterator movement call, container::operator[]
or iterator::operator*/->
call.
For some old compilers, such as gcc3.4.6, the *iterator cannot be used with the ternary
?
operator, like this:Even when var is the same type as the iterator’s
value_type
, the compiler fails to perform an auto conversion.
You can find example code demonstrating string storage in the and StlAdvancedFeaturesExample::storing_std_strings()
methods.