Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:44

0001 #ifndef  BOOST_SERIALIZATION_DETAIL_STACK_CONSTRUCTOR_HPP
0002 #define BOOST_SERIALIZATION_DETAIL_STACK_CONSTRUCTOR_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // stack_constructor.hpp: serialization for loading stl collections
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 #include <boost/aligned_storage.hpp>
0020 #include <boost/serialization/serialization.hpp>
0021 
0022 namespace boost{
0023 namespace serialization {
0024 namespace detail {
0025 
0026 // reserve space on stack for an object of type T without actually
0027 // construction such an object
0028 template<typename T >
0029 struct stack_allocate
0030 {
0031     T * address() {
0032         return static_cast<T*>(storage_.address());
0033     }
0034     T & reference() {
0035         return * address();
0036     }
0037 private:
0038     typedef typename boost::aligned_storage<
0039         sizeof(T),
0040         boost::alignment_of<T>::value
0041     > type;
0042     type storage_;
0043 };
0044 
0045 // construct element on the stack
0046 template<class Archive, class T>
0047 struct stack_construct : public stack_allocate<T>
0048 {
0049     stack_construct(Archive & ar, const unsigned int version){
0050         // note borland emits a no-op without the explicit namespace
0051         boost::serialization::load_construct_data_adl(
0052             ar,
0053             this->address(),
0054             version
0055         );
0056     }
0057     ~stack_construct(){
0058         this->address()->~T(); // undo load_construct_data above
0059     }
0060 };
0061 
0062 } // detail
0063 } // serialization
0064 } // boost
0065 
0066 #endif //  BOOST_SERIALIZATION_DETAIL_STACH_CONSTRUCTOR_HPP