diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index 14582b4f..29209df1 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -148,13 +148,12 @@ add_library(serialization ../src/stl_port.cpp ../src/text_iarchive.cpp ../src/text_oarchive.cpp - ../src/utf8_codecvt_facet.cpp ../src/void_cast.cpp ../src/xml_archive_exception.cpp ../src/xml_iarchive.cpp ../src/xml_oarchive.cpp ../src/xml_grammar.cpp -# ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' + ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' ) target_compile_options(serialization PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) @@ -167,6 +166,7 @@ add_library(wserialization ../src/xml_wiarchive.cpp ../src/xml_woarchive.cpp ../src/xml_wgrammar.cpp + ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"' ) target_compile_options(wserialization PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) @@ -247,10 +247,13 @@ serialization_test(test_iterators) serialization_test(test_iterators_base64) serialization_test(test_inclusion) serialization_test(test_smart_cast) -serialization_test(test_utf8_codecvt ../src/utf8_codecvt_facet) serialization_test(test_codecvt_null ../src/codecvt_null) -archive_test(test_array A) +archive_test(test_native_array A) +archive_test(test_boost_array A) +if(COMPILER_SUPPORTS_CXX11) + archive_test(test_array A) +endif() archive_test(test_binary) archive_test(test_bitset) archive_test(test_class_info_save) @@ -376,8 +379,7 @@ file(GLOB x RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*_w*.hpp" ) - -add_custom_target(wserialization_headers SOURCES ${x} "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/codecvt_null.hpp") +add_custom_target(wserialization_headers SOURCES ${x}) set_property(TARGET wserialization_headers PROPERTY FOLDER "wserialization") # end headers in IDE diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index f26353a0..cfa20e77 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -80,7 +80,6 @@ SOURCES = xml_iarchive xml_oarchive xml_archive_exception - utf8_codecvt_facet codecvt_null singleton ; diff --git a/include/boost/archive/basic_binary_iprimitive.hpp b/include/boost/archive/basic_binary_iprimitive.hpp index 5cab9916..40f45d9c 100644 --- a/include/boost/archive/basic_binary_iprimitive.hpp +++ b/include/boost/archive/basic_binary_iprimitive.hpp @@ -143,7 +143,7 @@ public: // the optimized load_array dispatches to load_binary template - void load_array(serialization::array& a, unsigned int) + void load_array(serialization::array_wrapper& a, unsigned int) { load_binary(a.address(),a.count()*sizeof(ValueType)); } diff --git a/include/boost/archive/basic_binary_oprimitive.hpp b/include/boost/archive/basic_binary_oprimitive.hpp index 8c7691dd..4b7f454b 100644 --- a/include/boost/archive/basic_binary_oprimitive.hpp +++ b/include/boost/archive/basic_binary_oprimitive.hpp @@ -137,11 +137,10 @@ public: struct apply : public boost::serialization::is_bitwise_serializable< T > {}; #endif }; - // the optimized save_array dispatches to save_binary template - void save_array(boost::serialization::array const& a, unsigned int) + void save_array(boost::serialization::array_wrapper const& a, unsigned int) { save_binary(a.address(),a.count()*sizeof(ValueType)); } diff --git a/include/boost/archive/basic_streambuf_locale_saver.hpp b/include/boost/archive/basic_streambuf_locale_saver.hpp index 6efc706a..5cd4b36f 100644 --- a/include/boost/archive/basic_streambuf_locale_saver.hpp +++ b/include/boost/archive/basic_streambuf_locale_saver.hpp @@ -60,27 +60,43 @@ private: }; template < typename Ch, class Tr > -class basic_ios_locale_saver : +class basic_istream_locale_saver : private boost::noncopyable { public: - explicit basic_ios_locale_saver(std::basic_ios &s) : - m_ios(s), + explicit basic_istream_locale_saver(std::basic_istream &s) : + m_istream(s), m_locale(s.getloc()) {} - ~basic_ios_locale_saver(){ - // libc++ doesn't support std::[w]ostream.sync() - // but gcc will throw an error if sync() isn't invoked - #ifndef _LIBCPP_VERSION - m_ios.sync(); - #endif - m_ios.imbue(m_locale); + ~basic_istream_locale_saver(){ + // libstdc++ crashes without this + m_istream.sync(); + m_istream.imbue(m_locale); } private: - std::basic_ios & m_ios; + std::basic_istream & m_istream; std::locale const m_locale; }; +template < typename Ch, class Tr > +class basic_ostream_locale_saver : + private boost::noncopyable +{ +public: + explicit basic_ostream_locale_saver(std::basic_ostream &s) : + m_ostream(s), + m_locale(s.getloc()) + {} + ~basic_ostream_locale_saver(){ + m_ostream.flush(); + m_ostream.imbue(m_locale); + } +private: + std::basic_ostream & m_ostream; + std::locale const m_locale; +}; + + } // archive } // boost diff --git a/include/boost/archive/basic_text_iprimitive.hpp b/include/boost/archive/basic_text_iprimitive.hpp index 3aa2710c..bf936b55 100644 --- a/include/boost/archive/basic_text_iprimitive.hpp +++ b/include/boost/archive/basic_text_iprimitive.hpp @@ -77,7 +77,7 @@ protected: // f) destroy new codecvt facet boost::archive::codecvt_null codecvt_null_facet; std::locale archive_locale; - basic_ios_locale_saver< + basic_istream_locale_saver< typename IStream::char_type, typename IStream::traits_type > locale_saver; diff --git a/include/boost/archive/basic_text_oprimitive.hpp b/include/boost/archive/basic_text_oprimitive.hpp index 5f79ef00..c9f8c591 100644 --- a/include/boost/archive/basic_text_oprimitive.hpp +++ b/include/boost/archive/basic_text_oprimitive.hpp @@ -80,7 +80,7 @@ protected: // f) destroy new codecvt facet boost::archive::codecvt_null codecvt_null_facet; std::locale archive_locale; - basic_ios_locale_saver< + basic_ostream_locale_saver< typename OStream::char_type, typename OStream::traits_type > locale_saver; diff --git a/include/boost/archive/detail/utf8_codecvt_facet.hpp b/include/boost/archive/detail/utf8_codecvt_facet.hpp index c72402c5..f630af5d 100644 --- a/include/boost/archive/detail/utf8_codecvt_facet.hpp +++ b/include/boost/archive/detail/utf8_codecvt_facet.hpp @@ -9,22 +9,24 @@ #include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace archive { namespace detail { +#define BOOST_UTF8_END_NAMESPACE }}} + #ifdef BOOST_NO_CXX11_HDR_CODECVT - #define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace archive { namespace detail { - #define BOOST_UTF8_DECL - #define BOOST_UTF8_END_NAMESPACE }}} - - #include - - #undef BOOST_UTF8_END_NAMESPACE - #undef BOOST_UTF8_DECL - #undef BOOST_UTF8_BEGIN_NAMESPACE + #include + BOOST_UTF8_BEGIN_NAMESPACE + typedef boost::locale::utf8_codecvt utf8_codecvt_facet; + BOOST_UTF8_END_NAMESPACE #else #include - namespace boost { namespace archive { namespace detail { + BOOST_UTF8_BEGIN_NAMESPACE typedef std::codecvt_utf8 utf8_codecvt_facet; - } } } + BOOST_UTF8_END_NAMESPACE #endif // BOOST_NO_CXX11_HDR_CODECVT +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE + #endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP + diff --git a/include/boost/archive/impl/basic_binary_iprimitive.ipp b/include/boost/archive/impl/basic_binary_iprimitive.ipp index 2cd10493..7082b003 100644 --- a/include/boost/archive/impl/basic_binary_iprimitive.ipp +++ b/include/boost/archive/impl/basic_binary_iprimitive.ipp @@ -161,42 +161,11 @@ basic_binary_iprimitive::basic_binary_iprimitive( {} #endif -// some libraries including stl and libcomo fail if the -// buffer isn't flushed before the code_cvt facet is changed. -// I think this is a bug. We explicity invoke sync to when -// we're done with the streambuf to work around this problem. -// Note that sync is a protected member of stream buff so we -// have to invoke it through a contrived derived class. -namespace detail { -// note: use "using" to get past msvc bug -using namespace std; -template -class input_streambuf_access : public std::basic_streambuf { - public: - virtual int sync(){ -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) - return this->basic_streambuf::sync(); -#else - return this->basic_streambuf::sync(); -#endif - } -}; -} // detail - -// scoped_ptr requires that archive_locale be a complete type at time of +// scoped_ptr requires that g be a complete type at time of // destruction so define destructor here rather than in the header template BOOST_ARCHIVE_OR_WARCHIVE_DECL -basic_binary_iprimitive::~basic_binary_iprimitive(){ - // push back unread characters - //destructor can't throw ! - BOOST_TRY{ - static_cast &>(m_sb).sync(); - } - BOOST_CATCH(...){ - } - BOOST_CATCH_END -} +basic_binary_iprimitive::~basic_binary_iprimitive(){} } // namespace archive } // namespace boost diff --git a/include/boost/archive/impl/basic_binary_oprimitive.ipp b/include/boost/archive/impl/basic_binary_oprimitive.ipp index db67d708..130831e4 100644 --- a/include/boost/archive/impl/basic_binary_oprimitive.ipp +++ b/include/boost/archive/impl/basic_binary_oprimitive.ipp @@ -114,30 +114,6 @@ basic_binary_oprimitive::basic_binary_oprimitive( {} #endif -/* -// some libraries including stl and libcomo fail if the -// buffer isn't flushed before the code_cvt facet is changed. -// I think this is a bug. We explicity invoke sync to when -// we're done with the streambuf to work around this problem. -// Note that sync is a protected member of stream buff so we -// have to invoke it through a contrived derived class. -namespace detail { -// note: use "using" to get past msvc bug -using namespace std; -template -class output_streambuf_access : public std::basic_streambuf { - public: - virtual int sync(){ -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) - return this->basic_streambuf::sync(); -#else - return this->basic_streambuf::sync(); -#endif - } -}; -} // detail -*/ - // scoped_ptr requires that g be a complete type at time of // destruction so define destructor here rather than in the header template diff --git a/include/boost/archive/impl/basic_text_oprimitive.ipp b/include/boost/archive/impl/basic_text_oprimitive.ipp index 5e3e203c..6030fd44 100644 --- a/include/boost/archive/impl/basic_text_oprimitive.ipp +++ b/include/boost/archive/impl/basic_text_oprimitive.ipp @@ -10,7 +10,7 @@ #include // NULL #include // std::copy - +#include // std::uncaught_exception #include #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ @@ -93,11 +93,7 @@ basic_text_oprimitive::basic_text_oprimitive( locale_saver(os) { if(! no_codecvt){ - // libc++ doesn't support std::wostream.sync() - // but gcc will throw an error if sync() isn't invoked - #ifndef _LIBCPP_VERSION - os_.sync(); - #endif + os_.flush(); os_.imbue(archive_locale); } os_ << std::noboolalpha; @@ -110,6 +106,8 @@ basic_text_oprimitive::basic_text_oprimitive( template BOOST_ARCHIVE_OR_WARCHIVE_DECL basic_text_oprimitive::~basic_text_oprimitive(){ + if(std::uncaught_exception()) + return; os << std::endl; } diff --git a/include/boost/archive/impl/xml_iarchive_impl.ipp b/include/boost/archive/impl/xml_iarchive_impl.ipp index 1933add3..7a3d6ef3 100644 --- a/include/boost/archive/impl/xml_iarchive_impl.ipp +++ b/include/boost/archive/impl/xml_iarchive_impl.ipp @@ -11,6 +11,8 @@ #include #include // memcpy #include // NULL +#include + #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::memcpy; @@ -187,6 +189,8 @@ xml_iarchive_impl::xml_iarchive_impl( template BOOST_ARCHIVE_DECL xml_iarchive_impl::~xml_iarchive_impl(){ + if(std::uncaught_exception()) + return; if(0 == (this->get_flags() & no_header)){ gimpl->windup(is); } diff --git a/include/boost/archive/impl/xml_oarchive_impl.ipp b/include/boost/archive/impl/xml_oarchive_impl.ipp index 48025a1f..e7138caf 100644 --- a/include/boost/archive/impl/xml_oarchive_impl.ipp +++ b/include/boost/archive/impl/xml_oarchive_impl.ipp @@ -10,6 +10,7 @@ #include #include // std::copy #include +#include #include // strlen #include // msvc 6.0 needs this to suppress warnings @@ -116,6 +117,8 @@ xml_oarchive_impl::xml_oarchive_impl( template BOOST_ARCHIVE_DECL xml_oarchive_impl::~xml_oarchive_impl(){ + if(std::uncaught_exception()) + return; if(0 == (this->get_flags() & no_header)){ save("\n"); } diff --git a/include/boost/archive/impl/xml_wiarchive_impl.ipp b/include/boost/archive/impl/xml_wiarchive_impl.ipp index 30314e1a..ee66c126 100644 --- a/include/boost/archive/impl/xml_wiarchive_impl.ipp +++ b/include/boost/archive/impl/xml_wiarchive_impl.ipp @@ -20,7 +20,7 @@ namespace std{ #include #include // std::copy - +#include // uncaught exception #include // Dinkumware and RogueWave #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) #include @@ -36,6 +36,8 @@ namespace std{ #include #include +#include + #include "basic_xml_grammar.hpp" namespace boost { @@ -163,6 +165,7 @@ xml_wiarchive_impl::xml_wiarchive_impl( is_.getloc(), new boost::archive::detail::utf8_codecvt_facet ); + // libstdc++ crashes without this is_.sync(); is_.imbue(l); } @@ -173,6 +176,8 @@ xml_wiarchive_impl::xml_wiarchive_impl( template BOOST_WARCHIVE_DECL xml_wiarchive_impl::~xml_wiarchive_impl(){ + if(std::uncaught_exception()) + return; if(0 == (this->get_flags() & no_header)){ gimpl->windup(is); } diff --git a/include/boost/archive/impl/xml_woarchive_impl.ipp b/include/boost/archive/impl/xml_woarchive_impl.ipp index 6fd5d7b2..40289273 100644 --- a/include/boost/archive/impl/xml_woarchive_impl.ipp +++ b/include/boost/archive/impl/xml_woarchive_impl.ipp @@ -13,6 +13,7 @@ #include #include // std::copy #include +#include #include // strlen #include // mbtowc @@ -30,6 +31,8 @@ namespace std{ #endif #include +#include + #include #include @@ -125,11 +128,7 @@ xml_woarchive_impl::xml_woarchive_impl( os_.getloc(), new boost::archive::detail::utf8_codecvt_facet ); - // libc++ doesn't support std::[w]ostream.sync() - // but gcc will throw an error if sync() isn't invoked - #ifndef _LIBCPP_VERSION - os_.sync(); - #endif + os_.flush(); os_.imbue(l); } if(0 == (flags & no_header)) @@ -139,6 +138,8 @@ xml_woarchive_impl::xml_woarchive_impl( template BOOST_WARCHIVE_DECL xml_woarchive_impl::~xml_woarchive_impl(){ + if(std::uncaught_exception()) + return; if(0 == (this->get_flags() & no_header)){ save(L"\n"); } diff --git a/include/boost/serialization/array.hpp b/include/boost/serialization/array.hpp index 97ac0c25..112a7505 100644 --- a/include/boost/serialization/array.hpp +++ b/include/boost/serialization/array.hpp @@ -6,13 +6,9 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include // msvc 6.0 needs this for warning suppression +//#include -#include -#include // std::size_t -#ifndef BOOST_NO_CXX11_HDR_ARRAY -#include -#endif +#include // msvc 6.0 needs this for warning suppression #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ @@ -23,11 +19,13 @@ namespace std{ #include #include #include +#include #include #include #include #include -#include +#include +#include namespace boost { namespace serialization { @@ -37,24 +35,27 @@ template struct use_array_optimization : boost::mpl::always {}; template -class array : - public wrapper_traits > +class array_wrapper : + public wrapper_traits > { -public: - typedef T value_type; - - array(value_type* t, std::size_t s) : - m_t(t), - m_element_count(s) - {} - array(const array & rhs) : +private: + array_wrapper & operator=(const array_wrapper & rhs); +public: + // note: I would like to make the copy constructor private but this breaks + // make_array. So I try to make make_array a friend - but that doesn't + // build. Need a C++ guru to explain this! + template + friend const boost::serialization::array_wrapper make_array( T* t, S s); + + array_wrapper(const array_wrapper & rhs) : m_t(rhs.m_t), m_element_count(rhs.m_element_count) {} - array & operator=(const array & rhs){ - m_t = rhs.m_t; - m_element_count = rhs.m_element_count; - } +public: + array_wrapper(T * t, std::size_t s) : + m_t(t), + m_element_count(s) + {} // default implementation template @@ -62,7 +63,7 @@ public: { // default implemention does the loop std::size_t c = count(); - value_type * t = address(); + T * t = address(); while(0 < c--) ar & boost::serialization::make_nvp("item", *t++); } @@ -99,7 +100,7 @@ public: serialize_optimized(ar,version,use_optimized()); } - value_type* address() const + T * address() const { return m_t; } @@ -108,26 +109,32 @@ public: { return m_element_count; } - + private: - value_type* m_t; - std::size_t m_element_count; + T * const m_t; + const std::size_t m_element_count; }; -template +template inline -const array< T > make_array( T* t, std::size_t s){ - return array< T >(t, s); +const array_wrapper< T > make_array( T* t, S s){ + const array_wrapper< T > a(t, s); + return a; } -// implement serialization for boost::array -template -void serialize(Archive& ar, boost::array& a, const unsigned int /* version */) -{ - ar & boost::serialization::make_nvp("elems", a.elems); -} +} } // end namespace boost::serialization + +// I can't figure out why BOOST_NO_CXX11_HDR_ARRAY +// has been set for clang-11. So just make sure +// it's reset now. Needs further research!!! + +#if defined(_LIBCPP_VERSION) +#undef BOOST_NO_CXX11_HDR_ARRAY +#endif #ifndef BOOST_NO_CXX11_HDR_ARRAY +#include +namespace boost { namespace serialization { // implement serialization for std::array template void serialize(Archive& ar, std::array& a, const unsigned int /* version */) @@ -138,8 +145,19 @@ void serialize(Archive& ar, std::array& a, const unsigned int /* version */ ); } +} } // end namespace boost::serialization #endif +#include + +namespace boost { namespace serialization { +// implement serialization for boost::array +template +void serialize(Archive& ar, boost::array& a, const unsigned int /* version */) +{ + ar & boost::serialization::make_nvp("elems", a.elems); +} + } } // end namespace boost::serialization #define BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(Archive) \ diff --git a/include/boost/serialization/nvp.hpp b/include/boost/serialization/nvp.hpp index 6a1eb826..60fd4240 100644 --- a/include/boost/serialization/nvp.hpp +++ b/include/boost/serialization/nvp.hpp @@ -39,15 +39,18 @@ struct nvp : public std::pair, public wrapper_traits > { +//private: + //friend const nvp< T > make_nvp(const char * name, T & t); + nvp(const nvp & rhs) : + // note: redundant cast works around borland issue + std::pair(rhs.first, (T*)rhs.second) + {} +public: explicit nvp(const char * name_, T & t) : // note: redundant cast works around borland issue // note: added _ to suppress useless gcc warning std::pair(name_, (T*)(& t)) {} - nvp(const nvp & rhs) : - // note: redundant cast works around borland issue - std::pair(rhs.first, (T*)rhs.second) - {} const char * name() const { return this->first; diff --git a/include/boost/serialization/valarray.hpp b/include/boost/serialization/valarray.hpp index d24fda54..efe102f6 100644 --- a/include/boost/serialization/valarray.hpp +++ b/include/boost/serialization/valarray.hpp @@ -40,20 +40,20 @@ namespace serialization { template void save( Archive & ar, const STD::valarray &t, const unsigned int /*file_version*/ ) { - const collection_size_type count(t.size()); - ar << BOOST_SERIALIZATION_NVP(count); - if (t.size()) - ar << make_array(detail::get_data(t), t.size()); + const collection_size_type count(t.size()); + ar << BOOST_SERIALIZATION_NVP(count); + if (t.size()) + ar << make_array(detail::get_data(t), t.size()); } template void load( Archive & ar, STD::valarray &t, const unsigned int /*file_version*/ ) { - collection_size_type count; - ar >> BOOST_SERIALIZATION_NVP(count); - t.resize(count); - if (t.size()) - ar >> make_array(detail::get_data(t), t.size()); + collection_size_type count; + ar >> BOOST_SERIALIZATION_NVP(count); + t.resize(count); + if (t.size()) + ar >> make_array(detail::get_data(t), t.size()); } // split non-intrusive serialization function member into separate diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp deleted file mode 100644 index c55c7e97..00000000 --- a/src/utf8_codecvt_facet.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Vladimir Prus 2004. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt -// or copy at http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_ARCHIVE_SOURCE -#include - -#include -#include - -#ifdef BOOST_NO_STD_WSTREAMBUF -#error "wide char i/o not supported on this platform" -#else - #ifdef BOOST_NO_CXX11_HDR_CODECVT - #define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace archive { namespace detail { - #define BOOST_UTF8_DECL - #define BOOST_UTF8_END_NAMESPACE }}} - #include - #undef BOOST_UTF8_END_NAMESPACE - #undef BOOST_UTF8_DECL - #undef BOOST_UTF8_BEGIN_NAMESPACE - #endif // BOOST_NO_CXX11_HDR_CODECVT -#endif // BOOST_NO_STD_WSTREAMBUF diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3a01845f..52dba6e4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,7 +59,7 @@ lib dll_polymorphic_derived2_lib ; test-suite "serialization" : - [ test-bsl-run_files test_array : A ] + [ test-bsl-run_files test_array : A : : [ requires cxx11_hdr_array ] ] # BOOST_NO_CXX11_HDR_ARRAY [ test-bsl-run_files test_binary ] [ test-bsl-run_files test_class_info_save ] [ test-bsl-run_files test_class_info_load ] @@ -138,17 +138,6 @@ if ! $(BOOST_ARCHIVE_LIST) { [ test-bsl-run test_iterators_base64 ] [ test-bsl-run test_smart_cast ] - [ test-bsl-run test_utf8_codecvt - : ../src/utf8_codecvt_facet - : - : ../../config/test/all//BOOST_NO_STD_WSTREAMBUF - ] - [ test-bsl-run test_codecvt_null - : ../src/codecvt_null - : - : ../../config/test/all//BOOST_NO_STD_WSTREAMBUF - ] - #[ test-bsl-run test_z ] # should fail compilation diff --git a/test/test_array.cpp b/test/test_array.cpp index 1971a784..d0941d92 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -20,123 +20,14 @@ namespace std{ using ::remove; } #endif -#include #include "test_tools.hpp" +#include #include #include -#include #include "A.hpp" #include "A.ipp" -template -int test_native_array(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - // test array of objects - const T a_array[10]={T(),T(),T(),T(),T(),T(),T(),T(),T(),T()}; - const T b_array[2][3]={{T(),T(),T()},{T(),T(),T()}}; - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - { - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("a_array", a_array); - oa << boost::serialization::make_nvp("b_array", b_array); - } - os.close(); - } - { - T a_array1[10]; - T b_array1[2][3]; - test_istream is(testfile, TEST_STREAM_FLAGS); - { - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("a_array", a_array1); - ia >> boost::serialization::make_nvp("b_array", b_array1); - } - is.close(); - BOOST_CHECK(std::equal(& a_array[0], & a_array[10], & a_array1[0])); - BOOST_CHECK(b_array[0][0] == b_array1[0][0]); - BOOST_CHECK(b_array[1][0] == b_array1[1][0]); - } - { - T a_array1[9]; - T b_array1[2][3]; - test_istream is(testfile, TEST_STREAM_FLAGS); - { - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - bool exception_invoked = false; - BOOST_TRY { - ia >> boost::serialization::make_nvp("a_array", a_array1); - ia >> boost::serialization::make_nvp("b_array", b_array1); - } - BOOST_CATCH (boost::archive::archive_exception ae){ - BOOST_CHECK( - boost::archive::archive_exception::array_size_too_short - == ae.code - ); - exception_invoked = true; - } - BOOST_CATCH_END - BOOST_CHECK(exception_invoked); - } - is.close(); - } - std::remove(testfile); - return EXIT_SUCCESS; -} - -template -int test_boost_array(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - // test array of objects - const boost::array a_array = {{T(),T(),T(),T(),T(),T(),T(),T(),T(),T()}}; - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("a_array", a_array); - } - { - boost::array a_array1; - test_istream is(testfile, TEST_STREAM_FLAGS); - { - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("a_array", a_array1); - } - is.close(); - BOOST_CHECK(std::equal(a_array.begin(), a_array.end(), a_array1.begin())); - } - { - boost::array a_array1; - test_istream is(testfile, TEST_STREAM_FLAGS); - { - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - bool exception_invoked = false; - BOOST_TRY { - ia >> boost::serialization::make_nvp("a_array", a_array1); - } - BOOST_CATCH (boost::archive::archive_exception ae){ - BOOST_CHECK( - boost::archive::archive_exception::array_size_too_short - == ae.code - ); - exception_invoked = true; - } - BOOST_CATCH_END - BOOST_CHECK(exception_invoked); - } - is.close(); - } - std::remove(testfile); - return EXIT_SUCCESS; -} - -#ifndef BOOST_NO_CXX11_HDR_ARRAY -#include - template int test_std_array(){ const char * testfile = boost::archive::tmpnam(NULL); @@ -182,22 +73,11 @@ int test_std_array(){ std::remove(testfile); return EXIT_SUCCESS; } -#endif -int test_main( int /* argc */, char* /* argv */[] ) -{ +int test_main( int /* argc */, char* /* argv */[] ){ int res; - // boost array - res = test_boost_array(); - if (res != EXIT_SUCCESS) - return EXIT_FAILURE; - // test an int array for which optimized versions should be available - res = test_boost_array(); - if (res != EXIT_SUCCESS) - return EXIT_FAILURE; // std array - #ifndef BOOST_NO_CXX11_HDR_ARRAY res = test_std_array(); if (res != EXIT_SUCCESS) return EXIT_FAILURE; @@ -205,17 +85,7 @@ int test_main( int /* argc */, char* /* argv */[] ) res = test_std_array(); if (res != EXIT_SUCCESS) return EXIT_FAILURE; - #endif - // native array - res = test_native_array(); - if (res != EXIT_SUCCESS) - return EXIT_FAILURE; - // test an int array for which optimized versions should be available - res = test_native_array(); - if (res != EXIT_SUCCESS) - return EXIT_FAILURE; - return EXIT_SUCCESS; }