1#ifndef BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
2#define BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER) && (_MSC_VER >= 1020)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// serialization/unordered_map.hpp:
11// serialization for stl unordered_map templates
12
13// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
14// (C) Copyright 2014 Jim Bell
15// Use, modification and distribution is subject to the Boost Software
16// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17// http://www.boost.org/LICENSE_1_0.txt)
18
19// See http://www.boost.org for updates, documentation, and revision history.
20
21#include <boost/config.hpp>
22
23#include <boost/serialization/utility.hpp>
24
25namespace boost {
26namespace serialization {
27namespace stl {
28
29// map input
30template<class Archive, class Container>
31struct archive_input_unordered_map
32{
33 inline void operator()(
34 Archive &ar,
35 Container &s,
36 const unsigned int v
37 ){
38 typedef typename Container::value_type type;
39 detail::stack_construct<Archive, type> t(ar, v);
40 // borland fails silently w/o full namespace
41 ar >> boost::serialization::make_nvp("item", t.reference());
42 std::pair<typename Container::const_iterator, bool> result =
43 s.insert(t.reference());
44 // note: the following presumes that the map::value_type was NOT tracked
45 // in the archive. This is the usual case, but here there is no way
46 // to determine that.
47 if(result.second){
48 ar.reset_object_address(
49 & (result.first->second),
50 & t.reference().second
51 );
52 }
53 }
54};
55
56// multimap input
57template<class Archive, class Container>
58struct archive_input_unordered_multimap
59{
60 inline void operator()(
61 Archive &ar,
62 Container &s,
63 const unsigned int v
64 ){
65 typedef typename Container::value_type type;
66 detail::stack_construct<Archive, type> t(ar, v);
67 // borland fails silently w/o full namespace
68 ar >> boost::serialization::make_nvp("item", t.reference());
69 typename Container::const_iterator result
70 = s.insert(t.reference());
71 // note: the following presumes that the map::value_type was NOT tracked
72 // in the archive. This is the usual case, but here there is no way
73 // to determine that.
74 ar.reset_object_address(
75 & result->second,
76 & t.reference()
77 );
78 }
79};
80
81} // stl
82} // namespace serialization
83} // namespace boost
84
85#endif // BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
86

source code of boost/boost/serialization/archive_input_unordered_map.hpp