Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:20

0001 /* Copyright 2023 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See https://www.boost.org/libs/unordered for library home page.
0007  */
0008 
0009 #ifndef BOOST_UNORDERED_DETAIL_ARCHIVE_CONSTRUCTED_HPP
0010 #define BOOST_UNORDERED_DETAIL_ARCHIVE_CONSTRUCTED_HPP
0011 
0012 #include <boost/unordered/detail/opt_storage.hpp>
0013 
0014 #include <boost/config.hpp>
0015 #include <boost/core/no_exceptions_support.hpp>
0016 #include <boost/core/noncopyable.hpp>
0017 #include <boost/core/serialization.hpp>
0018 
0019 namespace boost{
0020 namespace unordered{
0021 namespace detail{
0022 
0023 /* constructs a stack-based object from a serialization archive */
0024 
0025 template<typename T>
0026 struct archive_constructed:private noncopyable
0027 {
0028   template<class Archive>
0029   archive_constructed(const char* name,Archive& ar,unsigned int version)
0030   {
0031     core::load_construct_data_adl(ar,std::addressof(get()),version);
0032     BOOST_TRY{
0033       ar>>core::make_nvp(name,get());
0034     }
0035     BOOST_CATCH(...){
0036       get().~T();
0037       BOOST_RETHROW;
0038     }
0039     BOOST_CATCH_END
0040   }
0041 
0042   ~archive_constructed()
0043   {
0044     get().~T();
0045   }
0046 
0047 #if defined(BOOST_GCC)&&(BOOST_GCC>=4*10000+6*100)
0048 #define BOOST_UNORDERED_IGNORE_WSTRICT_ALIASING
0049 #endif
0050 
0051 #if defined(BOOST_UNORDERED_IGNORE_WSTRICT_ALIASING)
0052 #pragma GCC diagnostic push
0053 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
0054 #endif
0055 
0056   T& get(){return *space.address();}
0057 
0058 #if defined(BOOST_UNORDERED_IGNORE_WSTRICT_ALIASING)
0059 #pragma GCC diagnostic pop
0060 #undef BOOST_UNORDERED_IGNORE_WSTRICT_ALIASING
0061 #endif
0062 
0063 private:
0064   opt_storage<T> space;
0065 };
0066 
0067 } /* namespace detail */
0068 } /* namespace unordered */
0069 } /* namespace boost */
0070 
0071 #endif