mirror of
https://github.com/boostorg/serialization.git
synced 2026-02-23 16:02:13 +00:00
Miscellaneous fixes
This commit is contained in:
@@ -149,9 +149,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
|
||||
const void *address,
|
||||
std::size_t count
|
||||
){
|
||||
//BOOST_ASSERT(
|
||||
// static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count
|
||||
//);
|
||||
// BOOST_ASSERT(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max));
|
||||
// note: if the following assertions fail
|
||||
// a likely cause is that the output stream is set to "text"
|
||||
// mode where by cr characters recieve special treatment.
|
||||
@@ -161,9 +159,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
|
||||
// archive_exception(archive_exception::output_stream_error)
|
||||
// );
|
||||
// figure number of elements to output - round up
|
||||
count = ( count + sizeof(Elem) - 1)
|
||||
/ sizeof(Elem);
|
||||
BOOST_ASSERT(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max));
|
||||
count = ( count + sizeof(Elem) - 1) / sizeof(Elem);
|
||||
std::streamsize scount = m_sb.sputn(
|
||||
static_cast<const Elem *>(address),
|
||||
static_cast<std::streamsize>(count)
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#ifndef BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
|
||||
#define BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// head_iterator.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to 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)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace iterators {
|
||||
|
||||
template<class Predicate, class Base>
|
||||
class head_iterator
|
||||
: public boost::iterator_adaptor<
|
||||
head_iterator<Predicate, Base>,
|
||||
Base,
|
||||
use_default,
|
||||
single_pass_traversal_tag
|
||||
>
|
||||
{
|
||||
private:
|
||||
friend class iterator_core_access;
|
||||
typedef boost::iterator_adaptor<
|
||||
head_iterator<Predicate, Base>,
|
||||
Base,
|
||||
use_default,
|
||||
single_pass_traversal_tag
|
||||
> super_t;
|
||||
|
||||
typedef head_iterator<Predicate, Base> this_t;
|
||||
typedef super_t::value_type value_type;
|
||||
typedef super_t::reference reference_type;
|
||||
|
||||
reference_type dereference_impl(){
|
||||
if(! m_end){
|
||||
while(! m_predicate(* this->base_reference()))
|
||||
++ this->base_reference();
|
||||
m_end = true;
|
||||
}
|
||||
return * this->base_reference();
|
||||
}
|
||||
|
||||
reference_type dereference() const {
|
||||
return const_cast<this_t *>(this)->dereference_impl();
|
||||
}
|
||||
|
||||
void increment(){
|
||||
++base_reference();
|
||||
}
|
||||
Predicate m_predicate;
|
||||
bool m_end;
|
||||
public:
|
||||
template<class T>
|
||||
head_iterator(Predicate f, T start) :
|
||||
super_t(Base(start)),
|
||||
m_predicate(f),
|
||||
m_end(false)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
} // namespace iterators
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
|
||||
@@ -63,7 +63,7 @@ collection_load_impl(
|
||||
Archive & ar,
|
||||
T & t,
|
||||
collection_size_type count,
|
||||
item_version_type item_version
|
||||
item_version_type
|
||||
){
|
||||
t.resize(count);
|
||||
typename T::iterator hint;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/archive/basic_archive.hpp>
|
||||
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/collections_load_imp.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
|
||||
@@ -84,7 +84,9 @@ class extended_type_info_typeid :
|
||||
{
|
||||
public:
|
||||
extended_type_info_typeid() :
|
||||
typeid_system::extended_type_info_typeid_0(get_key())
|
||||
typeid_system::extended_type_info_typeid_0(
|
||||
boost::serialization::guid< T >()
|
||||
)
|
||||
{
|
||||
type_register(typeid(T));
|
||||
key_register();
|
||||
|
||||
@@ -123,13 +123,13 @@ class singleton : public singleton_module
|
||||
private:
|
||||
BOOST_DLLEXPORT static T & instance;
|
||||
// include this to provoke instantiation at pre-execution time
|
||||
static void use(T const &) {}
|
||||
static void use(T const *) {}
|
||||
BOOST_DLLEXPORT static T & get_instance() {
|
||||
static detail::singleton_wrapper< T > t;
|
||||
// refer to instance, causing it to be instantiated (and
|
||||
// initialized at startup on working compilers)
|
||||
BOOST_ASSERT(! detail::singleton_wrapper< T >::m_is_destroyed);
|
||||
use(instance);
|
||||
use(& instance);
|
||||
return static_cast<T &>(t);
|
||||
}
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user