Removed some (but not all) of the line endings I accidentally added while in VS.

Fixed a bunch of issues related to compiling unittests on VS.

Having a problem linking against boost unit tests, so can't run the tests yet.
This commit is contained in:
Shane
2013-07-18 21:42:37 -07:00
parent 66c9bc3647
commit da03627ff1
13 changed files with 3291 additions and 3271 deletions

View File

@@ -106,16 +106,26 @@ namespace cereal
void saveValue(double d) { itsWriter.Double(d); } void saveValue(double d) { itsWriter.Double(d); }
void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); } void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); }
void saveValue(char const * s) { itsWriter.String(s); } void saveValue(char const * s) { itsWriter.String(s); }
#ifdef _MSC_VER
template <class T> inline
typename std::enable_if<sizeof(T) == sizeof(std::uint32_t), void>::type
saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
template <class T> inline
typename std::enable_if<sizeof(T) != sizeof(std::uint32_t), void>::type
saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
void saveValue( unsigned long lu ){ saveLong( lu ); };
#endif
//! Save exotic arithmetic types as binary //! Save exotic arithmetic types as binary
template<class T> template<class T>
typename std::enable_if<std::is_arithmetic<T>::value && typename std::enable_if<std::is_arithmetic<T>::value &&
(sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long)), void>::type (sizeof(T) >= sizeof(long double) || sizeof(T) >= sizeof(long long)), void>::type
saveValue(T const & t) saveValue(T const & t)
{ {
auto base64string = base64::encode( reinterpret_cast<const unsigned char *>( &t ), sizeof(T) ); auto base64string = base64::encode( reinterpret_cast<const unsigned char *>( &t ), sizeof(T) );
saveValue( base64string ); saveValue( base64string );
} }
//! Write the name of the upcoming node and prepare object/array state //! Write the name of the upcoming node and prepare object/array state
/*! Since writeName is called for every value that is output, regardless of /*! Since writeName is called for every value that is output, regardless of
@@ -358,7 +368,7 @@ namespace cereal
}; };
//! Loads the size for a SizeTag //! Loads the size for a SizeTag
void loadSize(size_t & size) void loadSize(size_type & size)
{ {
size = (itsValueStack.rbegin() + 1)->value().Size(); size = (itsValueStack.rbegin() + 1)->value().Size();
} }

View File

@@ -1,326 +1,326 @@
#ifndef RAPIDJSON_WRITER_H_ #ifndef RAPIDJSON_WRITER_H_
#define RAPIDJSON_WRITER_H_ #define RAPIDJSON_WRITER_H_
#include "rapidjson.h" #include "rapidjson.h"
#include "internal/stack.h" #include "internal/stack.h"
#include "internal/strfunc.h" #include "internal/strfunc.h"
#include <cstdio> // snprintf() or _sprintf_s() #include <cstdio> // snprintf() or _sprintf_s()
#include <new> // placement new #include <new> // placement new
#include <limits> #include <limits>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant #pragma warning(disable : 4127) // conditional expression is constant
#endif #endif
namespace rapidjson { namespace rapidjson {
//! JSON writer //! JSON writer
/*! Writer implements the concept Handler. /*! Writer implements the concept Handler.
It generates JSON text by events to an output stream. It generates JSON text by events to an output stream.
User may programmatically calls the functions of a writer to generate JSON text. User may programmatically calls the functions of a writer to generate JSON text.
On the other side, a writer can also be passed to objects that generates events, On the other side, a writer can also be passed to objects that generates events,
for example Reader::Parse() and Document::Accept(). for example Reader::Parse() and Document::Accept().
\tparam Stream Type of ouptut stream. \tparam Stream Type of ouptut stream.
\tparam Encoding Encoding of both source strings and output. \tparam Encoding Encoding of both source strings and output.
\implements Handler \implements Handler
*/ */
template<typename Stream, typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> > template<typename Stream, typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
class Writer { class Writer {
public: public:
typedef typename Encoding::Ch Ch; typedef typename Encoding::Ch Ch;
Writer(Stream& stream, int precision = 20, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : Writer(Stream& stream, int precision = 20, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) :
stream_(stream), level_stack_(allocator, levelDepth * sizeof(Level)) stream_(stream), level_stack_(allocator, levelDepth * sizeof(Level))
{ {
#if _MSC_VER #if _MSC_VER
(void) sprintf_s(double_format, sizeof(double_format), "%%0.%dg", precision); (void) sprintf_s(double_format, sizeof(double_format), "%%0.%dg", precision);
(void) sprintf_s( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision ); (void) sprintf_s( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision );
#else #else
(void) snprintf(double_format, sizeof(double_format), "%%0.%dg", precision); (void) snprintf(double_format, sizeof(double_format), "%%0.%dg", precision);
(void) snprintf( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision ); (void) snprintf( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision );
#endif #endif
} }
protected: protected:
char double_format[32]; char double_format[32];
char long_double_format[32]; char long_double_format[32];
public: public:
//@name Implementation of Handler //@name Implementation of Handler
//@{ //@{
Writer& Null() { Prefix(kNullType); WriteNull(); return *this; } Writer& Null() { Prefix(kNullType); WriteNull(); return *this; }
Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; } Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; }
Writer& Int(int i) { Prefix(kNumberType); WriteInt(i); return *this; } Writer& Int(int i) { Prefix(kNumberType); WriteInt(i); return *this; }
Writer& Uint(unsigned u) { Prefix(kNumberType); WriteUint(u); return *this; } Writer& Uint(unsigned u) { Prefix(kNumberType); WriteUint(u); return *this; }
Writer& Int64(int64_t i64) { Prefix(kNumberType); WriteInt64(i64); return *this; } Writer& Int64(int64_t i64) { Prefix(kNumberType); WriteInt64(i64); return *this; }
Writer& Uint64(uint64_t u64) { Prefix(kNumberType); WriteUint64(u64); return *this; } Writer& Uint64(uint64_t u64) { Prefix(kNumberType); WriteUint64(u64); return *this; }
Writer& Double(double d) { Prefix(kNumberType); WriteDouble(d); return *this; } Writer& Double(double d) { Prefix(kNumberType); WriteDouble(d); return *this; }
Writer& LongDouble(long double d) { Prefix(kNumberType); WriteLongDouble(d); return *this; } Writer& LongDouble(long double d) { Prefix(kNumberType); WriteLongDouble(d); return *this; }
Writer& LongLong(long long d) { Prefix(kNumberType); WriteLongLong(d); return *this; } Writer& LongLong(long long d) { Prefix(kNumberType); WriteLongLong(d); return *this; }
Writer& ULongLong(unsigned long long d) { Prefix(kNumberType); WriteULongLong(d); return *this; } Writer& ULongLong(unsigned long long d) { Prefix(kNumberType); WriteULongLong(d); return *this; }
Writer& String(const Ch* str, SizeType length, bool copy = false) { Writer& String(const Ch* str, SizeType length, bool copy = false) {
(void)copy; (void)copy;
Prefix(kStringType); Prefix(kStringType);
WriteString(str, length); WriteString(str, length);
return *this; return *this;
} }
Writer& StartObject() { Writer& StartObject() {
Prefix(kObjectType); Prefix(kObjectType);
new (level_stack_.template Push<Level>()) Level(false); new (level_stack_.template Push<Level>()) Level(false);
WriteStartObject(); WriteStartObject();
return *this; return *this;
} }
Writer& EndObject(SizeType memberCount = 0) { Writer& EndObject(SizeType memberCount = 0) {
(void)memberCount; (void)memberCount;
RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));
RAPIDJSON_ASSERT(!level_stack_.template Top<Level>()->inArray); RAPIDJSON_ASSERT(!level_stack_.template Top<Level>()->inArray);
level_stack_.template Pop<Level>(1); level_stack_.template Pop<Level>(1);
WriteEndObject(); WriteEndObject();
return *this; return *this;
} }
Writer& StartArray() { Writer& StartArray() {
Prefix(kArrayType); Prefix(kArrayType);
new (level_stack_.template Push<Level>()) Level(true); new (level_stack_.template Push<Level>()) Level(true);
WriteStartArray(); WriteStartArray();
return *this; return *this;
} }
Writer& EndArray(SizeType elementCount = 0) { Writer& EndArray(SizeType elementCount = 0) {
(void)elementCount; (void)elementCount;
RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));
RAPIDJSON_ASSERT(level_stack_.template Top<Level>()->inArray); RAPIDJSON_ASSERT(level_stack_.template Top<Level>()->inArray);
level_stack_.template Pop<Level>(1); level_stack_.template Pop<Level>(1);
WriteEndArray(); WriteEndArray();
return *this; return *this;
} }
//@} //@}
//! Simpler but slower overload. //! Simpler but slower overload.
Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); } Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); }
protected: protected:
//! Information for each nested level //! Information for each nested level
struct Level { struct Level {
Level(bool inArray_) : inArray(inArray_), valueCount(0) {} Level(bool inArray_) : inArray(inArray_), valueCount(0) {}
bool inArray; //!< true if in array, otherwise in object bool inArray; //!< true if in array, otherwise in object
size_t valueCount; //!< number of values in this level size_t valueCount; //!< number of values in this level
}; };
static const size_t kDefaultLevelDepth = 32; static const size_t kDefaultLevelDepth = 32;
void WriteNull() { void WriteNull() {
stream_.Put('n'); stream_.Put('u'); stream_.Put('l'); stream_.Put('l'); stream_.Put('n'); stream_.Put('u'); stream_.Put('l'); stream_.Put('l');
} }
void WriteBool(bool b) { void WriteBool(bool b) {
if (b) { if (b) {
stream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e'); stream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e');
} }
else { else {
stream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e'); stream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e');
} }
} }
void WriteInt(int i) { void WriteInt(int i) {
if (i < 0) { if (i < 0) {
stream_.Put('-'); stream_.Put('-');
i = -i; i = -i;
} }
WriteUint((unsigned)i); WriteUint((unsigned)i);
} }
void WriteUint(unsigned u) { void WriteUint(unsigned u) {
char buffer[10]; char buffer[10];
char *p = buffer; char *p = buffer;
do { do {
*p++ = (u % 10) + '0'; *p++ = (u % 10) + '0';
u /= 10; u /= 10;
} while (u > 0); } while (u > 0);
do { do {
--p; --p;
stream_.Put(*p); stream_.Put(*p);
} while (p != buffer); } while (p != buffer);
} }
void WriteInt64(int64_t i64) { void WriteInt64(int64_t i64) {
if (i64 < 0) { if (i64 < 0) {
stream_.Put('-'); stream_.Put('-');
i64 = -i64; i64 = -i64;
} }
WriteUint64((uint64_t)i64); WriteUint64((uint64_t)i64);
} }
void WriteUint64(uint64_t u64) { void WriteUint64(uint64_t u64) {
char buffer[20]; char buffer[20];
char *p = buffer; char *p = buffer;
do { do {
*p++ = char(u64 % 10) + '0'; *p++ = char(u64 % 10) + '0';
u64 /= 10; u64 /= 10;
} while (u64 > 0); } while (u64 > 0);
do { do {
--p; --p;
stream_.Put(*p); stream_.Put(*p);
} while (p != buffer); } while (p != buffer);
} }
// cereal Temporary until constexpr support is added in RTM // cereal Temporary until constexpr support is added in RTM
#ifdef _MSC_VER #ifdef _MSC_VER
template <class Ch> template <class Ch>
bool characterOk( Ch c ) bool characterOk( Ch c )
{ {
return c < 256; return c < 256;
} }
template <> template <>
bool characterOk<char>( Ch ) bool characterOk<char>( Ch )
{ {
return true; return true;
} }
#else #else
template<class Ch> template<class Ch>
typename std::enable_if < std::numeric_limits<Ch>::max() < 265, bool>::type typename std::enable_if < std::numeric_limits<Ch>::max() < 265, bool>::type
characterOk( Ch c ) characterOk( Ch c )
{ {
return true; return true;
} }
template<class Ch> template<class Ch>
typename std::enable_if<std::numeric_limits<Ch>::max() >= 265, bool>::type typename std::enable_if<std::numeric_limits<Ch>::max() >= 265, bool>::type
characterOk(Ch c) characterOk(Ch c)
{ return c < 256; } { return c < 256; }
#endif #endif
//! \todo Optimization with custom double-to-string converter. //! \todo Optimization with custom double-to-string converter.
void WriteDouble(double d) { void WriteDouble(double d) {
char buffer[100]; char buffer[100];
#if _MSC_VER #if _MSC_VER
int ret = sprintf_s(buffer, sizeof(buffer), double_format, d); int ret = sprintf_s(buffer, sizeof(buffer), double_format, d);
#else #else
int ret = snprintf(buffer, sizeof(buffer), double_format, d); int ret = snprintf(buffer, sizeof(buffer), double_format, d);
#endif #endif
RAPIDJSON_ASSERT(ret >= 1); RAPIDJSON_ASSERT(ret >= 1);
for (int i = 0; i < ret; i++) for (int i = 0; i < ret; i++)
stream_.Put(buffer[i]); stream_.Put(buffer[i]);
} }
void WriteLongDouble(long double d) { void WriteLongDouble(long double d) {
char buffer[256]; char buffer[256];
#if _MSC_VER #if _MSC_VER
int ret = sprintf_s(buffer, sizeof(buffer), long_double_format, d); int ret = sprintf_s(buffer, sizeof(buffer), long_double_format, d);
#else #else
int ret = snprintf(buffer, sizeof(buffer), long_double_format, d); int ret = snprintf(buffer, sizeof(buffer), long_double_format, d);
#endif #endif
RAPIDJSON_ASSERT(ret >= 1); RAPIDJSON_ASSERT(ret >= 1);
for (int i = 0; i < ret; i++) for (int i = 0; i < ret; i++)
stream_.Put(buffer[i]); stream_.Put(buffer[i]);
} }
void WriteLongLong(long long d) { void WriteLongLong(long long d) {
char buffer[256]; char buffer[256];
#if _MSC_VER #if _MSC_VER
int ret = sprintf_s(buffer, sizeof(buffer), "%lld", d); int ret = sprintf_s(buffer, sizeof(buffer), "%lld", d);
#else #else
int ret = snprintf(buffer, sizeof(buffer), "%lld", d); int ret = snprintf(buffer, sizeof(buffer), "%lld", d);
#endif #endif
RAPIDJSON_ASSERT(ret >= 1); RAPIDJSON_ASSERT(ret >= 1);
for (int i = 0; i < ret; i++) for (int i = 0; i < ret; i++)
stream_.Put(buffer[i]); stream_.Put(buffer[i]);
} }
void WriteULongLong(unsigned long long d) { void WriteULongLong(unsigned long long d) {
char buffer[256]; char buffer[256];
#if _MSC_VER #if _MSC_VER
int ret = sprintf_s(buffer, sizeof(buffer), "%llu", d); int ret = sprintf_s(buffer, sizeof(buffer), "%llu", d);
#else #else
int ret = snprintf(buffer, sizeof(buffer), "%llu", d); int ret = snprintf(buffer, sizeof(buffer), "%llu", d);
#endif #endif
RAPIDJSON_ASSERT(ret >= 1); RAPIDJSON_ASSERT(ret >= 1);
for (int i = 0; i < ret; i++) for (int i = 0; i < ret; i++)
stream_.Put(buffer[i]); stream_.Put(buffer[i]);
} }
void WriteString(const Ch* str, SizeType length) { void WriteString(const Ch* str, SizeType length) {
static const char hexDigits[] = "0123456789ABCDEF"; static const char hexDigits[] = "0123456789ABCDEF";
static const char escape[256] = { static const char escape[256] = {
#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
//0 1 2 3 4 5 6 7 8 9 A B C D E F //0 1 2 3 4 5 6 7 8 9 A B C D E F
'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00
'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10
0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20
Z16, Z16, // 30~4F Z16, Z16, // 30~4F
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50
Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF
#undef Z16 #undef Z16
}; };
stream_.Put('\"'); stream_.Put('\"');
for (const Ch* p = str; p != str + length; ++p) { for (const Ch* p = str; p != str + length; ++p) {
if ((sizeof(Ch) == 1 || characterOk(*p)) && escape[(unsigned char)*p]) { if ((sizeof(Ch) == 1 || characterOk(*p)) && escape[(unsigned char)*p]) {
//if ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p]) { //if ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p]) {
stream_.Put('\\'); stream_.Put('\\');
stream_.Put(escape[(unsigned char)*p]); stream_.Put(escape[(unsigned char)*p]);
if (escape[(unsigned char)*p] == 'u') { if (escape[(unsigned char)*p] == 'u') {
stream_.Put('0'); stream_.Put('0');
stream_.Put('0'); stream_.Put('0');
stream_.Put(hexDigits[(*p) >> 4]); stream_.Put(hexDigits[(*p) >> 4]);
stream_.Put(hexDigits[(*p) & 0xF]); stream_.Put(hexDigits[(*p) & 0xF]);
} }
} }
else else
stream_.Put(*p); stream_.Put(*p);
} }
stream_.Put('\"'); stream_.Put('\"');
} }
void WriteStartObject() { stream_.Put('{'); } void WriteStartObject() { stream_.Put('{'); }
void WriteEndObject() { stream_.Put('}'); } void WriteEndObject() { stream_.Put('}'); }
void WriteStartArray() { stream_.Put('['); } void WriteStartArray() { stream_.Put('['); }
void WriteEndArray() { stream_.Put(']'); } void WriteEndArray() { stream_.Put(']'); }
void Prefix(Type type) { void Prefix(Type type) {
(void)type; (void)type;
if (level_stack_.GetSize() != 0) { // this value is not at root if (level_stack_.GetSize() != 0) { // this value is not at root
Level* level = level_stack_.template Top<Level>(); Level* level = level_stack_.template Top<Level>();
if (level->valueCount > 0) { if (level->valueCount > 0) {
if (level->inArray) if (level->inArray)
stream_.Put(','); // add comma if it is not the first element in array stream_.Put(','); // add comma if it is not the first element in array
else // in object else // in object
stream_.Put((level->valueCount % 2 == 0) ? ',' : ':'); stream_.Put((level->valueCount % 2 == 0) ? ',' : ':');
} }
if (!level->inArray && level->valueCount % 2 == 0) if (!level->inArray && level->valueCount % 2 == 0)
RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name
level->valueCount++; level->valueCount++;
} }
else else
RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType); RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);
} }
Stream& stream_; Stream& stream_;
internal::Stack<Allocator> level_stack_; internal::Stack<Allocator> level_stack_;
private: private:
// Prohibit assignment for VC C4512 warning // Prohibit assignment for VC C4512 warning
Writer& operator=(const Writer& w); Writer& operator=(const Writer& w);
}; };
} // namespace rapidjson } // namespace rapidjson
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif // RAPIDJSON_RAPIDJSON_H_ #endif // RAPIDJSON_RAPIDJSON_H_

View File

@@ -57,7 +57,7 @@ namespace cereal
ar( _CEREAL_NVP("type", bitset_detail::type::ulong) ); ar( _CEREAL_NVP("type", bitset_detail::type::ulong) );
ar( _CEREAL_NVP("data", b) ); ar( _CEREAL_NVP("data", b) );
} }
catch( std::overflow_error const & e ) catch( std::overflow_error const & )
{ {
try try
{ {
@@ -65,7 +65,7 @@ namespace cereal
ar( _CEREAL_NVP("type", bitset_detail::type::ullong) ); ar( _CEREAL_NVP("type", bitset_detail::type::ullong) );
ar( _CEREAL_NVP("data", b) ); ar( _CEREAL_NVP("data", b) );
} }
catch( std::overflow_error const & e ) catch( std::overflow_error const & )
{ {
ar( _CEREAL_NVP("type", bitset_detail::type::string) ); ar( _CEREAL_NVP("type", bitset_detail::type::string) );
ar( _CEREAL_NVP("data", bits.to_string()) ); ar( _CEREAL_NVP("data", bits.to_string()) );

View File

@@ -52,7 +52,7 @@ namespace cereal
size_type size; size_type size;
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
deque.resize( size ); deque.resize( static_cast<size_t>( size ) );
for( auto & i : deque ) for( auto & i : deque )
ar( i ); ar( i );

View File

@@ -58,7 +58,7 @@ namespace cereal
size_type size; size_type size;
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
forward_list.resize( size ); forward_list.resize( static_cast<size_t>( size ) );
for( auto & i : forward_list ) for( auto & i : forward_list )
ar( i ); ar( i );

View File

@@ -52,7 +52,7 @@ namespace cereal
size_type size; size_type size;
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
list.resize( size ); list.resize( static_cast<size_t>( size ) );
for( auto & i : list ) for( auto & i : list )
ar( i ); ar( i );

View File

@@ -39,7 +39,7 @@
#include <cereal/details/polymorphic_impl.hpp> #include <cereal/details/polymorphic_impl.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#define CONSTEXPR #define CONSTEXPR
#else #else
#define CONSTEXPR constexpr #define CONSTEXPR constexpr
#endif #endif
@@ -128,7 +128,7 @@ namespace cereal
default constructors, but on clang/gcc this will return false. So we also need to check for that here. default constructors, but on clang/gcc this will return false. So we also need to check for that here.
@internal */ @internal */
template<class Archive, class T> inline template<class Archive, class T> inline
typename std::enable_if<(std::is_default_constructible<T>::value typename std::enable_if<(std::is_default_constructible<T>::value
|| traits::has_load_and_allocate<T, Archive>::value) || traits::has_load_and_allocate<T, Archive>::value)
&& !std::is_abstract<T>::value, bool>::type && !std::is_abstract<T>::value, bool>::type
serialize_wrapper(Archive & ar, std::shared_ptr<T> & ptr, std::uint32_t const nameid) serialize_wrapper(Archive & ar, std::shared_ptr<T> & ptr, std::uint32_t const nameid)
@@ -146,7 +146,7 @@ namespace cereal
using the derived class serialize function using the derived class serialize function
@internal */ @internal */
template<class Archive, class T, class D> inline template<class Archive, class T, class D> inline
typename std::enable_if<(std::is_default_constructible<T>::value typename std::enable_if<(std::is_default_constructible<T>::value
|| traits::has_load_and_allocate<T, Archive>::value) || traits::has_load_and_allocate<T, Archive>::value)
&& !std::is_abstract<T>::value, bool>::type && !std::is_abstract<T>::value, bool>::type
serialize_wrapper(Archive & ar, std::unique_ptr<T, D> & ptr, std::uint32_t const nameid) serialize_wrapper(Archive & ar, std::unique_ptr<T, D> & ptr, std::uint32_t const nameid)
@@ -166,7 +166,7 @@ namespace cereal
this was a polymorphic type serialized by its proper pointer type this was a polymorphic type serialized by its proper pointer type
@internal */ @internal */
template<class Archive, class T> inline template<class Archive, class T> inline
typename std::enable_if<(!std::is_default_constructible<T>::value typename std::enable_if<(!std::is_default_constructible<T>::value
&& !traits::has_load_and_allocate<T, Archive>::value) && !traits::has_load_and_allocate<T, Archive>::value)
|| std::is_abstract<T>::value, bool>::type || std::is_abstract<T>::value, bool>::type
serialize_wrapper(Archive &, std::shared_ptr<T> &, std::uint32_t const nameid) serialize_wrapper(Archive &, std::shared_ptr<T> &, std::uint32_t const nameid)

View File

@@ -55,7 +55,7 @@ namespace cereal
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
map.clear(); map.clear();
map.reserve( size ); map.reserve( static_cast<std::size_t>( size ) );
for( size_type i = 0; i < size; ++i ) for( size_type i = 0; i < size; ++i )
{ {

View File

@@ -55,7 +55,7 @@ namespace cereal
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
set.clear(); set.clear();
set.reserve( size ); set.reserve( static_cast<std::size_t>( size ) );
for( size_type i = 0; i < size; ++i ) for( size_type i = 0; i < size; ++i )
{ {

View File

@@ -54,8 +54,8 @@ namespace cereal
size_type vectorSize; size_type vectorSize;
ar( make_size_tag( vectorSize ) ); ar( make_size_tag( vectorSize ) );
vector.resize( vectorSize ); vector.resize( static_cast<std::size_t>( vectorSize ) );
ar( binary_data( vector.data(), vectorSize * sizeof(T) ) ); ar( binary_data( vector.data(), static_cast<std::size_t>( vectorSize ) * sizeof(T) ) );
} }
//! Serialization for non-arithmetic (and bool) vector types //! Serialization for non-arithmetic (and bool) vector types

View File

@@ -217,6 +217,6 @@ int main()
// std::cout << cereal::traits::has_load_and_allocate<A, cereal::JSONInputArchive>::value << std::endl; // std::cout << cereal::traits::has_load_and_allocate<A, cereal::JSONInputArchive>::value << std::endl;
// ar( ptr ); // ar( ptr );
//} //}
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -66,7 +66,7 @@
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_54;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -74,7 +74,7 @@
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_54;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -89,6 +89,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libboost_unit_test_framework-vc120-mt-gd-1_55.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -113,6 +114,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libboost_unit_test_framework-vc120-mt-1_55.lib;libboost_test_exec_monitor-vc120-mt-1_55.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">