mirror of
https://github.com/boostorg/multi_index.git
synced 2025-05-09 23:14:04 +00:00
merged [58485] and [59443] from trunk
[SVN r59525]
This commit is contained in:
parent
efce67f27b
commit
215d795984
@ -31,6 +31,8 @@ Acknowledgements
|
||||
<h2>Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="#boost_1_43">Boost 1.43 release</a></li>
|
||||
<li><a href="#boost_1_42">Boost 1.42 release</a></li>
|
||||
<li><a href="#boost_1_41">Boost 1.41 release</a></li>
|
||||
<li><a href="#boost_1_38">Boost 1.38 release</a></li>
|
||||
<li><a href="#boost_1_37">Boost 1.37 release</a></li>
|
||||
@ -41,6 +43,30 @@ Acknowledgements
|
||||
<li><a href="#boost_1_33">Boost 1.33 release</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a name="boost_1_43">Boost 1.43 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="../../serialization/doc/serialization.html#constructors">Serialization
|
||||
of non default constructible values</a> is now properly supported
|
||||
through user-provided facilities <code>save_construct_data</code> and
|
||||
<code>load_construct_data</code>.
|
||||
<code>multi_index_container</code> serialization
|
||||
<a href="../../serialization/doc/tutorial.html#versioning">class version</a> has been
|
||||
bumped from 1 to 2.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_42">Boost 1.42 release</a></h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Maintenance fixes.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h2><a name="boost_1_41">Boost 1.41 release</a></h2>
|
||||
<p>
|
||||
<ul>
|
||||
@ -282,9 +308,9 @@ Acknowledgements
|
||||
|
||||
<br>
|
||||
|
||||
<p>Revised September 22nd 2009</p>
|
||||
<p>Revised February 3rd 2010</p>
|
||||
|
||||
<p>© Copyright 2003-2009 Joaquín M López Muñoz.
|
||||
<p>© Copyright 2003-2010 Joaquín M López Muñoz.
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
|
||||
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
|
75
include/boost/multi_index/detail/serialization_version.hpp
Normal file
75
include/boost/multi_index/detail/serialization_version.hpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* Copyright 2003-2010 Joaquin M Lopez Munoz.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_SERIALIZATION_VERSION_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_SERIALIZATION_VERSION_HPP
|
||||
|
||||
#if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
#include <boost/serialization/version.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
/* Helper class for storing and retrieving a given type serialization class
|
||||
* version while avoiding saving the number multiple times in the same
|
||||
* archive.
|
||||
* Behavior undefined if template partial specialization is not supported.
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
struct serialization_version
|
||||
{
|
||||
serialization_version():
|
||||
value(boost::serialization::version<serialization_version>::value){}
|
||||
|
||||
serialization_version& operator=(unsigned int x){value=x;return *this;};
|
||||
|
||||
operator unsigned int()const{return value;}
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
|
||||
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||
|
||||
template<class Archive>
|
||||
void save(Archive&,const unsigned int)const{}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive&,const unsigned int version)
|
||||
{
|
||||
this->value=version;
|
||||
}
|
||||
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
namespace serialization {
|
||||
template<typename T>
|
||||
struct version<boost::multi_index::detail::serialization_version<T> >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned int,value=version<T>::value);
|
||||
};
|
||||
} /* namespace serialization */
|
||||
#endif
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif
|
@ -1,6 +1,6 @@
|
||||
/* Multiply indexed container.
|
||||
*
|
||||
* Copyright 2003-2009 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2010 Joaquin M Lopez Munoz.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -44,6 +44,7 @@
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
|
||||
#include <boost/multi_index/detail/archive_constructed.hpp>
|
||||
#include <boost/multi_index/detail/serialization_version.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
@ -634,16 +635,20 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
|
||||
{
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
const serialization::collection_size_type s(size_());
|
||||
const serialization::collection_size_type s(size_());
|
||||
const detail::serialization_version<value_type> value_version;
|
||||
ar<<serialization::make_nvp("count",s);
|
||||
ar<<serialization::make_nvp("value_version",value_version);
|
||||
#else
|
||||
const std::size_t s=size_();
|
||||
const std::size_t s=size_();
|
||||
const unsigned int value_version=0;
|
||||
ar<<serialization::make_nvp("count",s);
|
||||
#endif
|
||||
|
||||
index_saver_type sm(bfm_allocator::member,s);
|
||||
|
||||
for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){
|
||||
serialization::save_construct_data_adl(ar,&*it,value_version);
|
||||
ar<<serialization::make_nvp("item",*it);
|
||||
sm.add(it.get_node(),ar,version);
|
||||
}
|
||||
@ -660,7 +665,8 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
|
||||
clear_();
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
serialization::collection_size_type s;
|
||||
serialization::collection_size_type s;
|
||||
detail::serialization_version<value_type> value_version;
|
||||
if(version<1){
|
||||
std::size_t sz;
|
||||
ar>>serialization::make_nvp("count",sz);
|
||||
@ -669,15 +675,22 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
|
||||
else{
|
||||
ar>>serialization::make_nvp("count",s);
|
||||
}
|
||||
if(version<2){
|
||||
value_version=0;
|
||||
}
|
||||
else{
|
||||
ar>>serialization::make_nvp("value_version",value_version);
|
||||
}
|
||||
#else
|
||||
std::size_t s;
|
||||
std::size_t s;
|
||||
unsigned int value_version=0;
|
||||
ar>>serialization::make_nvp("count",s);
|
||||
#endif
|
||||
|
||||
index_loader_type lm(bfm_allocator::member,s);
|
||||
|
||||
for(std::size_t n=0;n<s;++n){
|
||||
detail::archive_constructed<Value> value("item",ar,version);
|
||||
detail::archive_constructed<Value> value("item",ar,value_version);
|
||||
std::pair<node_type*,bool> p=insert_(
|
||||
value.get(),super::end().get_node());
|
||||
if(!p.second)throw_exception(
|
||||
@ -1100,8 +1113,9 @@ void swap(
|
||||
|
||||
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)&&\
|
||||
!defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
/* Serialization class version bump as we now serialize the size
|
||||
* through boost::serialization::collection_size_type.
|
||||
/* class version = 1 : we now serialize the size through
|
||||
* boost::serialization::collection_size_type.
|
||||
* class version = 2 : proper use of {save|load}_construct_data.
|
||||
*/
|
||||
|
||||
namespace serialization {
|
||||
@ -1110,7 +1124,7 @@ struct version<
|
||||
boost::multi_index_container<Value,IndexSpecifierList,Allocator>
|
||||
>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned int,value=1);
|
||||
BOOST_STATIC_CONSTANT(unsigned int,value=2);
|
||||
};
|
||||
} /* namespace serialization */
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Boost.MultiIndex test for serialization, part 3.
|
||||
*
|
||||
* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
||||
* Copyright 2003-2010 Joaquin M Lopez Munoz.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -13,9 +13,67 @@
|
||||
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/key_extractors.hpp>
|
||||
#include "non_std_allocator.hpp"
|
||||
|
||||
struct non_default_ctble
|
||||
{
|
||||
non_default_ctble(int n_):n(n_){}
|
||||
|
||||
bool operator==(const non_default_ctble& x)const{return n==x.n;}
|
||||
|
||||
int n;
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
namespace boost{
|
||||
namespace serialization{
|
||||
#endif
|
||||
|
||||
template<class Archive>
|
||||
void save_construct_data(
|
||||
Archive& ar,const non_default_ctble* p,const unsigned int version)
|
||||
{
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
if(version<3)return;
|
||||
#endif
|
||||
|
||||
ar<<boost::serialization::make_nvp("n",p->n);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load_construct_data(
|
||||
Archive& ar,non_default_ctble* p,const unsigned int version)
|
||||
{
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
if(version<3)return;
|
||||
#endif
|
||||
|
||||
int n=0;
|
||||
ar>>boost::serialization::make_nvp("n",n);
|
||||
::new(p)non_default_ctble(n);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive&,non_default_ctble&,const unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
||||
} /* namespace serialization */
|
||||
} /* namespace boost*/
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace serialization{
|
||||
template<> struct version<non_default_ctble>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned int,value=3);
|
||||
};
|
||||
} /* namespace serialization */
|
||||
} /* namespace boost*/
|
||||
|
||||
using namespace boost::multi_index;
|
||||
|
||||
void test_serialization3()
|
||||
@ -96,4 +154,19 @@ void test_serialization3()
|
||||
ia>>it2;
|
||||
BOOST_CHECK(it2==hs2.end(buc));
|
||||
}
|
||||
|
||||
{
|
||||
typedef multi_index_container<
|
||||
non_default_ctble,
|
||||
indexed_by<
|
||||
ordered_unique<
|
||||
BOOST_MULTI_INDEX_MEMBER(non_default_ctble,int,n)
|
||||
>
|
||||
>
|
||||
> multi_index_t;
|
||||
|
||||
multi_index_t m;
|
||||
for(int i=0;i<100;++i)m.insert(non_default_ctble(i));
|
||||
test_serialization(m);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user