Pack required boost code together.
[xy_vsfilter.git] / src / thirdparty / boost_1_47_0 / boost / multi_index / detail / archive_constructed.hpp
bloba38630868cb7632229ba80b9f4b77c9981cb714e
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.
7 */
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)
13 #pragma once
14 #endif
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>
23 namespace boost{
25 namespace multi_index{
27 namespace detail{
29 /* constructs a stack-based object from a serialization archive */
31 template<typename T>
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);
38 BOOST_TRY{
39 ar>>get();
41 BOOST_CATCH(...){
42 (&get())->~T();
43 BOOST_RETHROW;
45 BOOST_CATCH_END
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);
52 BOOST_TRY{
53 ar>>serialization::make_nvp(name,get());
55 BOOST_CATCH(...){
56 (&get())->~T();
57 BOOST_RETHROW;
59 BOOST_CATCH_END
62 ~archive_constructed()
64 (&get())->~T();
67 T& get(){return *static_cast<T*>(static_cast<void*>(&space));}
69 private:
70 typename aligned_storage<sizeof(T),alignment_of<T>::value>::type space;
73 } /* namespace multi_index::detail */
75 } /* namespace multi_index */
77 } /* namespace boost */
79 #endif