1 /* Copyright 2003-2008 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_ARCHIVE_CONSTRUCTED_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_ARCHIVE_CONSTRUCTED_HPP
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/detail/no_exceptions_support.hpp>
18 #include <boost/noncopyable.hpp>
19 #include <boost/serialization/serialization.hpp>
20 #include <boost/type_traits/aligned_storage.hpp>
21 #include <boost/type_traits/alignment_of.hpp>
25 namespace multi_index
{
29 /* constructs a stack-based object from a serialization archive */
32 struct archive_constructed
:private noncopyable
34 template<class Archive
>
35 archive_constructed(Archive
& ar
,const unsigned int version
)
37 serialization::load_construct_data_adl(ar
,&get(),version
);
48 template<class Archive
>
49 archive_constructed(const char* name
,Archive
& ar
,const unsigned int version
)
51 serialization::load_construct_data_adl(ar
,&get(),version
);
53 ar
>>serialization::make_nvp(name
,get());
62 ~archive_constructed()
67 T
& get(){return *static_cast<T
*>(static_cast<void*>(&space
));}
70 typename aligned_storage
<sizeof(T
),alignment_of
<T
>::value
>::type space
;
73 } /* namespace multi_index::detail */
75 } /* namespace multi_index */
77 } /* namespace boost */