4 #include <boost/container/flat_map.hpp>
5 #include <boost/container/flat_set.hpp>
10 template<
typename Stream,
typename T,
typename... A>
11 inline void pack( Stream& s,
const flat_set<T, A...>& value, uint32_t _max_depth ) {
15 auto itr = value.begin();
16 auto end = value.end();
22 template<
typename Stream,
typename T,
typename... A>
23 inline void unpack( Stream& s, flat_set<T, A...>& value, uint32_t _max_depth ) {
29 for( uint32_t i = 0; i < size.
value; ++i )
33 value.insert( std::move(tmp) );
36 template<
typename Stream,
typename K,
typename... V>
37 inline void pack( Stream& s,
const flat_map<K,V...>& value, uint32_t _max_depth ) {
41 auto itr = value.begin();
42 auto end = value.end();
48 template<
typename Stream,
typename K,
typename V,
typename... A>
49 inline void unpack( Stream& s, flat_map<K,V,A...>& value, uint32_t _max_depth )
56 for( uint32_t i = 0; i < size.
value; ++i )
60 value.insert( std::move(tmp) );
64 template<
typename Stream,
typename T,
typename A>
65 void pack( Stream& s,
const bip::vector<T,A>& value, uint32_t _max_depth ) {
69 if( !std::is_fundamental<T>::value ) {
70 auto itr = value.begin();
71 auto end = value.end();
77 s.write( (
const char*)value.data(), value.size() );
81 template<
typename Stream,
typename T,
typename A>
82 void unpack( Stream& s, bip::vector<T,A>& value, uint32_t _max_depth ) {
86 unpack( s, size, _max_depth );
87 if( !std::is_fundamental<T>::value ) {
89 for( uint64_t i = 0; i < size; i++ )
91 if( i >= value.size() )
92 value.resize( std::min(
static_cast<uint64_t
>(2*value.size()), size.value ) );
93 unpack( s, value[i], _max_depth );
97 s.read( (
char*)value.data(), value.size() );
104 template<
typename T,
typename... A>
109 std::vector<variant> vars(var.size());
111 for(
const auto& item : var )
112 vars[i++] =
variant( item, _max_depth );
115 template<
typename T,
typename... A>
122 vo.reserve( vars.size() );
123 for(
const auto& item : vars )
124 vo.insert( item.as<T>(_max_depth) );
127 template<
typename K,
typename... T>
132 std::vector< variant > vars(var.size());
134 for(
const auto& item : var )
135 vars[i++] =
variant( item, _max_depth );
138 template<
typename K,
typename T,
typename... A>
145 for(
const auto& item : vars )
146 vo.insert( item.as<std::pair<K,T>>(_max_depth) );