diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index b45b5dbb..38d5c94d 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -138,9 +138,9 @@ else() add_definitions( "-DBOOST_ALL_DYN_LINK=1") add_definitions( "-DBOOST_ALL_NO_LIB=1") add_definitions( "-DBOOST_LIB_DIAGNOSTICS=1") + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(VISIBILITY_INLINES_HIDDEN) endif() -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(VISIBILITY_INLINES_HIDDEN) ########################### # library builds @@ -178,8 +178,6 @@ add_library(serialization ${LINK_TYPE} ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' ) -# target_compile_options(serialization PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) - add_library(wserialization ${LINK_TYPE} ../src/codecvt_null.cpp ../src/basic_text_wiprimitive.cpp @@ -192,8 +190,6 @@ add_library(wserialization ${LINK_TYPE} ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' ) -#target_compile_options(wserialization PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) - # end library build ########################### diff --git a/doc/contents.html b/doc/contents.html index f5308ad7..86395023 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -253,7 +253,7 @@ function initialize() {
Archive Implementations
Serialization Declarations -
Serialization Implementations +
Serialization Implementations
Files Which Implement the Library
diff --git a/include/boost/serialization/optional.hpp b/include/boost/serialization/optional.hpp index 0e79ea7f..45bad916 100644 --- a/include/boost/serialization/optional.hpp +++ b/include/boost/serialization/optional.hpp @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include // function specializations must be defined in the appropriate // namespace - boost::serialization @@ -39,6 +41,15 @@ void save( const boost::optional< T > & t, const unsigned int /*version*/ ){ + // It is an inherent limitation to the serialization of optional.hpp + // that the underlying type must be either a pointer or must have a + // default constructor. It's possible that this could change sometime + // in the future, but for now, one will have to work around it. This can + // be done by serialization the optional as optional + BOOST_STATIC_ASSERT( + boost::detail::has_default_constructor::value + || boost::is_pointer::value + ); const bool tflag = t.is_initialized(); ar << boost::serialization::make_nvp("initialized", tflag); if (tflag){ @@ -65,20 +76,25 @@ void load( ){ bool tflag; ar >> boost::serialization::make_nvp("initialized", tflag); - t.reset(); - if (tflag){ - boost::serialization::item_version_type item_version(0); - boost::archive::library_version_type library_version( - ar.get_library_version() - ); - if(boost::archive::library_version_type(3) < library_version){ - // item_version is handled as an attribute so it doesnt need an NVP - ar >> BOOST_SERIALIZATION_NVP(item_version); - } - detail::stack_allocate t_new; - ar >> boost::serialization::make_nvp("value", t_new.reference()); - t = boost::move(t_new.reference()); + if(! tflag){ + t.reset(); + return; } + + boost::serialization::item_version_type item_version(0); + boost::archive::library_version_type library_version( + ar.get_library_version() + ); + if(boost::archive::library_version_type(3) < library_version){ + ar >> BOOST_SERIALIZATION_NVP(item_version); + } + detail::stack_allocate tp; + ar >> boost::serialization::make_nvp("value", tp.reference()); + t.reset(boost::move(tp.reference())); + ar.reset_object_address( + t.get_ptr(), + & tp.reference() + ); } template diff --git a/src/basic_archive.cpp b/src/basic_archive.cpp index 5391021a..54d24b90 100644 --- a/src/basic_archive.cpp +++ b/src/basic_archive.cpp @@ -76,10 +76,11 @@ BOOST_ARCHIVE_SIGNATURE(){ // 12- improved serialization of collections // 13- simplified visibility, removed Borland, removed pfto // 14- improved visibility, refactor map/set +// 15- corrections to optional and collection loading BOOST_SYMBOL_VISIBLE library_version_type BOOST_ARCHIVE_VERSION(){ - return library_version_type(14); + return library_version_type(15); } } // namespace archive diff --git a/test/test_z.cpp b/test/test_z.cpp index 02611375..b1902cde 100644 --- a/test/test_z.cpp +++ b/test/test_z.cpp @@ -22,11 +22,13 @@ struct Foo { return mBar; } + bool operator==(const Foo & rhs) const { + return mBar == rhs.mBar; + } private: int mBar; }; - namespace boost { namespace serialization { @@ -40,16 +42,15 @@ template inline void save_construct_data(Archive & ar, const Foo* foo, const unsigned int /*version*/) { std::cout << __FUNCTION__ << " called" << std::endl; - ar << foo->bar(); + ar & foo->bar(); } - template inline void load_construct_data(Archive & ar, Foo* foo, const unsigned int /*version*/) { std::cout << __FUNCTION__ << " called" << std::endl; int bar; - ar >> bar; + ar & bar; ::new(foo) Foo(bar); } @@ -68,6 +69,8 @@ int main() std::istringstream inStream(outStream.str()); boost::archive::text_iarchive inArchive(inStream); inArchive & newFoo; + + return !(newFoo == oldFoo); } #elif 0