mirror of
https://github.com/boostorg/multi_index.git
synced 2025-05-09 15:04:03 +00:00
fixed container size serialization in LLP64
This commit is contained in:
parent
3ad3171006
commit
343cb4c6f3
@ -78,6 +78,13 @@ Acknowledgements
|
|||||||
of equivalent elements
|
of equivalent elements
|
||||||
(<a href="https://github.com/boostorg/multi_index/issues/68">issue #68</a>).
|
(<a href="https://github.com/boostorg/multi_index/issues/68">issue #68</a>).
|
||||||
</li>
|
</li>
|
||||||
|
<li>Serialization now uses <code>std::size_t</code> instead of <code>unsigned long</code>
|
||||||
|
to save and load the size of a <code>multi_index_container</code>
|
||||||
|
(<code>unsigned long</code> is smaller than <code>std::size_t</code> in LLP64 data models).
|
||||||
|
<code>multi_index_container</code> serialization
|
||||||
|
<a href="../../serialization/doc/tutorial.html#versioning">class version</a> has been
|
||||||
|
bumped from 3 to 4 to reflect this change.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -786,7 +793,7 @@ Acknowledgements
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<p>Revised May 21st 2023</p>
|
<p>Revised May 22nd 2023</p>
|
||||||
|
|
||||||
<p>© Copyright 2003-2023 Joaquín M López Muñoz.
|
<p>© Copyright 2003-2023 Joaquín M López Muñoz.
|
||||||
Distributed under the Boost Software
|
Distributed under the Boost Software
|
||||||
|
@ -1119,7 +1119,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
|
|||||||
template<class Archive>
|
template<class Archive>
|
||||||
void save(Archive& ar,const unsigned int version)const
|
void save(Archive& ar,const unsigned int version)const
|
||||||
{
|
{
|
||||||
const unsigned long s(size_());
|
const std::size_t s(size_());
|
||||||
const detail::serialization_version<value_type> value_version;
|
const detail::serialization_version<value_type> value_version;
|
||||||
ar<<core::make_nvp("count",s);
|
ar<<core::make_nvp("count",s);
|
||||||
ar<<core::make_nvp("value_version",value_version);
|
ar<<core::make_nvp("value_version",value_version);
|
||||||
@ -1143,25 +1143,31 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
|
|||||||
BOOST_MULTI_INDEX_CHECK_INVARIANT;
|
BOOST_MULTI_INDEX_CHECK_INVARIANT;
|
||||||
|
|
||||||
clear_();
|
clear_();
|
||||||
unsigned long s;
|
std::size_t s;
|
||||||
detail::serialization_version<value_type> value_version;
|
detail::serialization_version<value_type> value_version;
|
||||||
if(version<1){
|
if(version<1){
|
||||||
std::size_t sz;
|
std::size_t sz;
|
||||||
ar>>core::make_nvp("count",sz);
|
ar>>core::make_nvp("count",sz);
|
||||||
s=static_cast<unsigned long>(sz);
|
s=static_cast<std::size_t>(sz);
|
||||||
}
|
}
|
||||||
else if(version<3){
|
else if(version<3){
|
||||||
#if defined(BOOST_MULTI_INDEX_ENABLE_SERIALIZATION_COMPATIBILITY_V2)
|
#if defined(BOOST_MULTI_INDEX_ENABLE_SERIALIZATION_COMPATIBILITY_V2)
|
||||||
serialization::collection_size_type csz;
|
serialization::collection_size_type csz;
|
||||||
ar>>core::make_nvp("count",csz);
|
ar>>core::make_nvp("count",csz);
|
||||||
s=static_cast<unsigned long>(csz);
|
s=static_cast<std::size_t>(csz);
|
||||||
#else
|
#else
|
||||||
ar>>core::make_nvp("count",s);
|
ar>>core::make_nvp("count",s);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else if(version<4){
|
||||||
|
unsigned long ul;
|
||||||
|
ar>>core::make_nvp("count",ul);
|
||||||
|
s=static_cast<std::size_t>(ul);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
ar>>core::make_nvp("count",s);
|
ar>>core::make_nvp("count",s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version<2){
|
if(version<2){
|
||||||
value_version=0;
|
value_version=0;
|
||||||
}
|
}
|
||||||
@ -1569,6 +1575,8 @@ void swap(
|
|||||||
* class version = 3 : dropped boost::serialization::collection_size_type
|
* class version = 3 : dropped boost::serialization::collection_size_type
|
||||||
* in favor of unsigned long --this allows us to provide serialization
|
* in favor of unsigned long --this allows us to provide serialization
|
||||||
* support without including any header from Boost.Serialization.
|
* support without including any header from Boost.Serialization.
|
||||||
|
* class version = 4 : uses std::size_t rather than unsigned long (which
|
||||||
|
* is smaller in LLP64 data models).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace serialization {
|
namespace serialization {
|
||||||
@ -1577,7 +1585,7 @@ struct version<
|
|||||||
boost::multi_index_container<Value,IndexSpecifierList,Allocator>
|
boost::multi_index_container<Value,IndexSpecifierList,Allocator>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
BOOST_STATIC_CONSTANT(int,value=3);
|
BOOST_STATIC_CONSTANT(int,value=4);
|
||||||
};
|
};
|
||||||
} /* namespace serialization */
|
} /* namespace serialization */
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user