Dear all,
I am learning to use the serialization library and I am having some
difficulties in using hash_map.
In the code below if I change to std::map it works fine.
#include <cstddef> // NULL
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
template
void save_setting (StringType application_name, SettingKeyType key,
SettingValueType value)
{
typedef stdext::hash_map Config;
static stdext::hash_map app_configs; // key =
application_name, value = settings map.
Config cfg = app_configs[application_name];
cfg[key] = value;
StringType file_name = application_name + ".cfg"; // Compose
configuration file name.
std::ofstream ofs (file_name.c_str ());
boost::archive::text_oarchive oa (ofs);
oa << cfg;
}
int main(int argc, char *argv[])
{
save_setting ("test_app", 1, "value1");
}
However if I try to use stdext::hash_map then it fails to compile with the
following error:
1>c:\boost_1_37_0\boost\serialization\access.hpp(109) : error C2039:
'serialize' : is not a member of 'stdext::hash_map<_Kty,_Ty>'
1> with
1> [
1> _Kty=int,
1> _Ty=std::string
1> ]
It is most likely related to the fact that hash_map is not in the std
namespace.
I have searched the boost-users list and I have found this:
http://lists.boost.org/boost-users/2005/08/13183.php
but it refers to a GNU/Linux environment.
Has this been addressed in 1.37 (that's the version I am using) ?
Any suggestions ?
Thank you in advance for your help.
--
Mauricio Gomes