Chris@16: #ifndef BOOST_SERIALIZATION_DETAIL_STACH_CONSTRUCTOR_HPP Chris@16: #define BOOST_SERIALIZATION_DETAIL_STACH_CONSTRUCTOR_HPP Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@101: // stack_constructor.hpp: serialization for loading stl collections Chris@16: Chris@16: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost{ Chris@16: namespace serialization { Chris@16: namespace detail { Chris@16: Chris@16: // reserve space on stack for an object of type T without actually Chris@16: // construction such an object Chris@16: template Chris@16: struct stack_allocate Chris@16: { Chris@16: T * address() { Chris@16: return static_cast(storage_.address()); Chris@16: } Chris@16: T & reference() { Chris@16: return * address(); Chris@16: } Chris@16: private: Chris@101: typedef typename boost::aligned_storage< Chris@16: sizeof(T), Chris@16: #if BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x560)) Chris@16: 8 Chris@16: #else Chris@16: boost::alignment_of::value Chris@16: #endif Chris@16: > type; Chris@16: type storage_; Chris@16: }; Chris@16: Chris@16: // construct element on the stack Chris@16: template Chris@16: struct stack_construct : public stack_allocate Chris@16: { Chris@16: stack_construct(Archive & ar, const unsigned int version){ Chris@16: // note borland emits a no-op without the explicit namespace Chris@16: boost::serialization::load_construct_data_adl( Chris@16: ar, Chris@16: this->address(), Chris@16: version Chris@16: ); Chris@16: } Chris@16: ~stack_construct(){ Chris@16: this->address()->~T(); // undo load_construct_data above Chris@16: } Chris@16: }; Chris@16: Chris@16: } // detail Chris@16: } // serializaition Chris@16: } // boost Chris@16: Chris@16: #endif // BOOST_SERIALIZATION_DETAIL_STACH_CONSTRUCTOR_HPP