Boost logo

Boost Users :

Subject: [Boost-users] hash_map use with serialization in Visual Studio 2005
From: Mauricio Gomes (mg_at_[hidden])
Date: 2008-11-25 13:32:04

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 <hash_map>

#include <boost/archive/tmpdir.hpp>

#include <boost/archive/text_iarchive.hpp>

#include <boost/archive/text_oarchive.hpp>

#include <boost/serialization/base_object.hpp>

#include <boost/serialization/utility.hpp>

#include <boost/serialization/list.hpp>

#include <boost/serialization/hash_map.hpp>

#include <boost/serialization/map.hpp>

#include <boost/serialization/assume_abstract.hpp>
template <typename StringType, typename SettingKeyType,
void save_setting (StringType application_name, SettingKeyType key,
SettingValueType value)
    typedef stdext::hash_map<SettingKeyType, SettingValueType> Config;
    static stdext::hash_map<StringType, Config> 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<std::string, int, std::string> ("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
I have searched the boost-users list and I have found this:
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

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at