Skip to content

Commit a248e3a

Browse files
committed
Merge branch 'develop' for 1.1.1 release
2 parents 81ec271 + 94d49c4 commit a248e3a

File tree

18 files changed

+215
-116
lines changed

18 files changed

+215
-116
lines changed

include/cereal/access.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ namespace cereal
403403
404404
@code{cpp}
405405
struct MyType {};
406-
CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( cereal::XMLInputArchive, MyType, cereal::specialization::member_load_save );
406+
CEREAL_SPECIALIZE_FOR_ARCHIVE( cereal::XMLInputArchive, MyType, cereal::specialization::member_load_save );
407407
@endcode
408408
409409
@relates specialize

include/cereal/archives/json.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ namespace cereal
580580
{
581581
search();
582582

583-
val = itsIteratorStack.back().value().GetInt();
583+
val = static_cast<T>( itsIteratorStack.back().value().GetInt() );
584584
++itsIteratorStack.back();
585585
}
586586

@@ -592,7 +592,7 @@ namespace cereal
592592
{
593593
search();
594594

595-
val = itsIteratorStack.back().value().GetUint();
595+
val = static_cast<T>( itsIteratorStack.back().value().GetUint() );
596596
++itsIteratorStack.back();
597597
}
598598

include/cereal/archives/xml.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,12 @@ namespace cereal
233233
itsOS << value << std::ends;
234234

235235
const auto strValue = itsOS.str();
236-
// if there is the first or the last character in string is whitespace then add xml:space attribute
237-
// the last character has index length-2 because there is \0 character at end added with std::ends
238-
if( !strValue.empty() && ( xml_detail::isWhitespace( strValue[0] ) || xml_detail::isWhitespace( strValue[strValue.length() - 2] ) ) )
236+
237+
// If the first or last character is a whitespace, add xml:space attribute
238+
// the string always contains a '\0' added by std::ends, so the last character is at len-2 and an 'empty'
239+
// string has a length of 1 or lower
240+
const auto len = strValue.length();
241+
if ( len > 1 && ( xml_detail::isWhitespace( strValue[0] ) || xml_detail::isWhitespace( strValue[len - 2] ) ) )
239242
{
240243
itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "xml:space", "preserve" ) );
241244
}
@@ -510,13 +513,13 @@ namespace cereal
510513
//! Load an int8_t from the current top node (ensures we parse entire number)
511514
void loadValue( int8_t & value )
512515
{
513-
int32_t val; loadValue( val ); value = val;
516+
int32_t val; loadValue( val ); value = static_cast<int8_t>( val );
514517
}
515518

516519
//! Load a uint8_t from the current top node (ensures we parse entire number)
517520
void loadValue( uint8_t & value )
518521
{
519-
uint32_t val; loadValue( val ); value = val;
522+
uint32_t val; loadValue( val ); value = static_cast<uint8_t>( val );
520523
}
521524

522525
//! Loads a type best represented as an unsigned long from the current top node

include/cereal/cereal.hpp

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ namespace cereal
239239
OutputArchive(ArchiveType * const derived) : self(derived), itsCurrentPointerId(1), itsCurrentPolymorphicTypeId(1)
240240
{ }
241241

242+
OutputArchive & operator=( OutputArchive const & ) = delete;
243+
242244
//! Serializes all passed in data
243245
/*! This is the primary interface for serializing data with an archive */
244246
template <class ... Types> inline
@@ -364,11 +366,18 @@ namespace cereal
364366
}
365367

366368
//! Helper macro that expands the requirements for activating an overload
367-
#define PROCESS_IF(name) \
368-
traits::EnableIf<traits::has_##name<T, ArchiveType>::value, \
369-
!traits::has_invalid_output_versioning<T, ArchiveType>::value, \
370-
(traits::is_specialized_##name<T, ArchiveType>::value || \
371-
traits::is_output_serializable<T, ArchiveType>::value)> = traits::sfinae
369+
/*! Requirements:
370+
Has the requested serialization function
371+
Does not have version and unversioned at the same time
372+
Is output serializable AND
373+
is specialized for this type of function OR
374+
has no specialization at all */
375+
#define PROCESS_IF(name) \
376+
traits::EnableIf<traits::has_##name<T, ArchiveType>::value, \
377+
!traits::has_invalid_output_versioning<T, ArchiveType>::value, \
378+
(traits::is_output_serializable<T, ArchiveType>::value && \
379+
(traits::is_specialized_##name<T, ArchiveType>::value || \
380+
!traits::is_specialized<T, ArchiveType>::value))> = traits::sfinae
372381

373382
//! Member serialization
374383
template <class T, PROCESS_IF(member_serialize)> inline
@@ -420,7 +429,6 @@ namespace cereal
420429

421430
//! Empty class specialization
422431
template <class T, traits::EnableIf<(Flags & AllowEmptyClassElision),
423-
!traits::is_specialized<T, ArchiveType>::value,
424432
!traits::is_output_serializable<T, ArchiveType>::value,
425433
std::is_empty<T>::value> = traits::sfinae> inline
426434
ArchiveType & processImpl(T const &)
@@ -430,11 +438,10 @@ namespace cereal
430438

431439
//! No matching serialization
432440
/*! Invalid if we have invalid output versioning or
433-
we have no specialization, are not output serializable, and either
441+
we are not output serializable, and either
434442
don't allow empty class ellision or allow it but are not serializing an empty class */
435443
template <class T, traits::EnableIf<traits::has_invalid_output_versioning<T, ArchiveType>::value ||
436-
(!traits::is_specialized<T, ArchiveType>::value &&
437-
!traits::is_output_serializable<T, ArchiveType>::value &&
444+
(!traits::is_output_serializable<T, ArchiveType>::value &&
438445
(!(Flags & AllowEmptyClassElision) || ((Flags & AllowEmptyClassElision) && !std::is_empty<T>::value)))> = traits::sfinae> inline
439446
ArchiveType & processImpl(T const &)
440447
{
@@ -587,6 +594,8 @@ namespace cereal
587594
itsVersionedTypes()
588595
{ }
589596

597+
InputArchive & operator=( InputArchive const & ) = delete;
598+
590599
//! Serializes all passed in data
591600
/*! This is the primary interface for serializing data with an archive */
592601
template <class ... Types> inline
@@ -725,11 +734,18 @@ namespace cereal
725734
}
726735

727736
//! Helper macro that expands the requirements for activating an overload
728-
#define PROCESS_IF(name) \
729-
traits::EnableIf<traits::has_##name<T, ArchiveType>::value, \
730-
!traits::has_invalid_input_versioning<T, ArchiveType>::value, \
731-
(traits::is_specialized_##name<T, ArchiveType>::value || \
732-
traits::is_input_serializable<T, ArchiveType>::value)> = traits::sfinae
737+
/*! Requirements:
738+
Has the requested serialization function
739+
Does not have version and unversioned at the same time
740+
Is input serializable AND
741+
is specialized for this type of function OR
742+
has no specialization at all */
743+
#define PROCESS_IF(name) \
744+
traits::EnableIf<traits::has_##name<T, ArchiveType>::value, \
745+
!traits::has_invalid_input_versioning<T, ArchiveType>::value, \
746+
(traits::is_input_serializable<T, ArchiveType>::value && \
747+
(traits::is_specialized_##name<T, ArchiveType>::value || \
748+
!traits::is_specialized<T, ArchiveType>::value))> = traits::sfinae
733749

734750
//! Member serialization
735751
template <class T, PROCESS_IF(member_serialize)> inline
@@ -787,7 +803,6 @@ namespace cereal
787803

788804
//! Empty class specialization
789805
template <class T, traits::EnableIf<(Flags & AllowEmptyClassElision),
790-
!traits::is_specialized<T, ArchiveType>::value,
791806
!traits::is_input_serializable<T, ArchiveType>::value,
792807
std::is_empty<T>::value> = traits::sfinae> inline
793808
ArchiveType & processImpl(T const &)
@@ -797,11 +812,10 @@ namespace cereal
797812

798813
//! No matching serialization
799814
/*! Invalid if we have invalid input versioning or
800-
we have no specialization, are not input serializable, and either
815+
we are not input serializable, and either
801816
don't allow empty class ellision or allow it but are not serializing an empty class */
802817
template <class T, traits::EnableIf<traits::has_invalid_input_versioning<T, ArchiveType>::value ||
803-
(!traits::is_specialized<T, ArchiveType>::value &&
804-
!traits::is_input_serializable<T, ArchiveType>::value &&
818+
(!traits::is_input_serializable<T, ArchiveType>::value &&
805819
(!(Flags & AllowEmptyClassElision) || ((Flags & AllowEmptyClassElision) && !std::is_empty<T>::value)))> = traits::sfinae> inline
806820
ArchiveType & processImpl(T const &)
807821
{

include/cereal/details/helpers.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ namespace cereal
147147
static_assert( !std::is_base_of<detail::NameValuePairCore, T>::value,
148148
"Cannot pair a name to a NameValuePair" );
149149

150+
NameValuePair & operator=( NameValuePair const & ) = delete;
151+
150152
public:
151153
//! Constructs a new NameValuePair
152154
/*! @param n The name of the pair
@@ -254,6 +256,8 @@ namespace cereal
254256
T,
255257
typename std::decay<T>::type>::type;
256258

259+
SizeTag & operator=( SizeTag const & ) = delete;
260+
257261
public:
258262
SizeTag( T && sz ) : size(std::forward<T>(sz)) {}
259263

@@ -298,6 +302,8 @@ namespace cereal
298302
/*! @internal */
299303
MapItem( Key && key_, Value && value_ ) : key(std::forward<Key>(key_)), value(std::forward<Value>(value_)) {}
300304

305+
MapItem & operator=( MapItem const & ) = delete;
306+
301307
KeyType key;
302308
ValueType value;
303309

include/cereal/details/traits.hpp

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -884,54 +884,6 @@ namespace cereal
884884
(has_non_member_load<T, InputArchive>::value && has_non_member_save<T, OutputArchive>::value) ||
885885
(has_non_member_versioned_load<T, InputArchive>::value && has_non_member_versioned_save<T, OutputArchive>::value)> {};
886886

887-
// ######################################################################
888-
namespace detail
889-
{
890-
template <class T, class OutputArchive>
891-
struct count_output_serializers : std::integral_constant<int,
892-
has_member_save<T, OutputArchive>::value +
893-
has_non_member_save<T, OutputArchive>::value +
894-
has_member_serialize<T, OutputArchive>::value +
895-
has_non_member_serialize<T, OutputArchive>::value +
896-
has_member_save_minimal<T, OutputArchive>::value +
897-
has_non_member_save_minimal<T, OutputArchive>::value +
898-
/*-versioned---------------------------------------------------------*/
899-
has_member_versioned_save<T, OutputArchive>::value +
900-
has_non_member_versioned_save<T, OutputArchive>::value +
901-
has_member_versioned_serialize<T, OutputArchive>::value +
902-
has_non_member_versioned_serialize<T, OutputArchive>::value +
903-
has_member_versioned_save_minimal<T, OutputArchive>::value +
904-
has_non_member_versioned_save_minimal<T, OutputArchive>::value> {};
905-
}
906-
907-
template <class T, class OutputArchive>
908-
struct is_output_serializable : std::integral_constant<bool,
909-
detail::count_output_serializers<T, OutputArchive>::value == 1> {};
910-
911-
// ######################################################################
912-
namespace detail
913-
{
914-
template <class T, class InputArchive>
915-
struct count_input_serializers : std::integral_constant<int,
916-
has_member_load<T, InputArchive>::value +
917-
has_non_member_load<T, InputArchive>::value +
918-
has_member_serialize<T, InputArchive>::value +
919-
has_non_member_serialize<T, InputArchive>::value +
920-
has_member_load_minimal<T, InputArchive>::value +
921-
has_non_member_load_minimal<T, InputArchive>::value +
922-
/*-versioned---------------------------------------------------------*/
923-
has_member_versioned_load<T, InputArchive>::value +
924-
has_non_member_versioned_load<T, InputArchive>::value +
925-
has_member_versioned_serialize<T, InputArchive>::value +
926-
has_non_member_versioned_serialize<T, InputArchive>::value +
927-
has_member_versioned_load_minimal<T, InputArchive>::value +
928-
has_non_member_versioned_load_minimal<T, InputArchive>::value> {};
929-
}
930-
931-
template <class T, class InputArchive>
932-
struct is_input_serializable : std::integral_constant<bool,
933-
detail::count_input_serializers<T, InputArchive>::value == 1> {};
934-
935887
// ######################################################################
936888
template <class T, class OutputArchive>
937889
struct has_invalid_output_versioning : std::integral_constant<bool,
@@ -970,15 +922,15 @@ namespace cereal
970922

971923
#undef CEREAL_MAKE_IS_SPECIALIZED_IMPL
972924

973-
//! Considered an error if specialization exists for more than one type
925+
//! Number of specializations detected
974926
template <class T, class A>
975-
struct is_specialized_error : std::integral_constant<bool,
976-
(is_specialized_member_serialize<T, A>::value +
977-
is_specialized_member_load_save<T, A>::value +
978-
is_specialized_member_load_save_minimal<T, A>::value +
979-
is_specialized_non_member_serialize<T, A>::value +
980-
is_specialized_non_member_load_save<T, A>::value +
981-
is_specialized_non_member_load_save_minimal<T, A>::value) <= 1> {};
927+
struct count_specializations : std::integral_constant<int,
928+
is_specialized_member_serialize<T, A>::value +
929+
is_specialized_member_load_save<T, A>::value +
930+
is_specialized_member_load_save_minimal<T, A>::value +
931+
is_specialized_non_member_serialize<T, A>::value +
932+
is_specialized_non_member_load_save<T, A>::value +
933+
is_specialized_non_member_load_save_minimal<T, A>::value> {};
982934
} // namespace detail
983935

984936
//! Check if any specialization exists for a type
@@ -991,7 +943,7 @@ namespace cereal
991943
detail::is_specialized_non_member_load_save<T, A>::value ||
992944
detail::is_specialized_non_member_load_save_minimal<T, A>::value>
993945
{
994-
static_assert(detail::is_specialized_error<T, A>::value, "More than one explicit specialization detected for type.");
946+
static_assert(detail::count_specializations<T, A>::value <= 1, "More than one explicit specialization detected for type.");
995947
};
996948

997949
//! Create the static assertion for some specialization
@@ -1056,6 +1008,60 @@ namespace cereal
10561008
!(is_specialized_member_serialize<T, InputArchive>::value ||
10571009
is_specialized_member_load<T, InputArchive>::value))> {};
10581010

1011+
// ######################################################################
1012+
namespace detail
1013+
{
1014+
//! The number of output serialization functions available
1015+
/*! If specialization is being used, we'll count only those; otherwise we'll count everything */
1016+
template <class T, class OutputArchive>
1017+
struct count_output_serializers : std::integral_constant<int,
1018+
count_specializations<T, OutputArchive>::value ? count_specializations<T, OutputArchive>::value :
1019+
has_member_save<T, OutputArchive>::value +
1020+
has_non_member_save<T, OutputArchive>::value +
1021+
has_member_serialize<T, OutputArchive>::value +
1022+
has_non_member_serialize<T, OutputArchive>::value +
1023+
has_member_save_minimal<T, OutputArchive>::value +
1024+
has_non_member_save_minimal<T, OutputArchive>::value +
1025+
/*-versioned---------------------------------------------------------*/
1026+
has_member_versioned_save<T, OutputArchive>::value +
1027+
has_non_member_versioned_save<T, OutputArchive>::value +
1028+
has_member_versioned_serialize<T, OutputArchive>::value +
1029+
has_non_member_versioned_serialize<T, OutputArchive>::value +
1030+
has_member_versioned_save_minimal<T, OutputArchive>::value +
1031+
has_non_member_versioned_save_minimal<T, OutputArchive>::value> {};
1032+
}
1033+
1034+
template <class T, class OutputArchive>
1035+
struct is_output_serializable : std::integral_constant<bool,
1036+
detail::count_output_serializers<T, OutputArchive>::value == 1> {};
1037+
1038+
// ######################################################################
1039+
namespace detail
1040+
{
1041+
//! The number of input serialization functions available
1042+
/*! If specialization is being used, we'll count only those; otherwise we'll count everything */
1043+
template <class T, class InputArchive>
1044+
struct count_input_serializers : std::integral_constant<int,
1045+
count_specializations<T, InputArchive>::value ? count_specializations<T, InputArchive>::value :
1046+
has_member_load<T, InputArchive>::value +
1047+
has_non_member_load<T, InputArchive>::value +
1048+
has_member_serialize<T, InputArchive>::value +
1049+
has_non_member_serialize<T, InputArchive>::value +
1050+
has_member_load_minimal<T, InputArchive>::value +
1051+
has_non_member_load_minimal<T, InputArchive>::value +
1052+
/*-versioned---------------------------------------------------------*/
1053+
has_member_versioned_load<T, InputArchive>::value +
1054+
has_non_member_versioned_load<T, InputArchive>::value +
1055+
has_member_versioned_serialize<T, InputArchive>::value +
1056+
has_non_member_versioned_serialize<T, InputArchive>::value +
1057+
has_member_versioned_load_minimal<T, InputArchive>::value +
1058+
has_non_member_versioned_load_minimal<T, InputArchive>::value> {};
1059+
}
1060+
1061+
template <class T, class InputArchive>
1062+
struct is_input_serializable : std::integral_constant<bool,
1063+
detail::count_input_serializers<T, InputArchive>::value == 1> {};
1064+
10591065
// ######################################################################
10601066
// Base Class Support
10611067
namespace detail

include/cereal/external/rapidjson/genericstream.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
#include "rapidjson.h"
66
#include <iostream>
77

8+
#ifdef _MSC_VER
9+
#pragma warning(push)
10+
#pragma warning(disable: 4127) // conditional expression is constant
11+
#pragma warning(disable: 4512) // assignment operator could not be generated
12+
#pragma warning(disable: 4100) // unreferenced formal parameter
13+
#endif
14+
815
namespace rapidjson {
916

1017
//! Wrapper of std::istream for input.
@@ -91,4 +98,8 @@ namespace rapidjson {
9198

9299
} // namespace rapidjson
93100

101+
// On MSVC, restore warnings state
102+
#ifdef _MSC_VER
103+
#pragma warning(pop)
104+
#endif
94105
#endif // RAPIDJSON_GENERICSTREAM_H_

include/cereal/external/rapidjson/reader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#ifdef _MSC_VER
2424
#pragma warning(push)
2525
#pragma warning(disable : 4127) // conditional expression is constant
26+
#pragma warning(disable : 4702) // uncreachable code
2627
#endif
2728

2829
#ifndef RAPIDJSON_PARSE_ERROR

include/cereal/external/rapidxml/rapidxml.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifdef _MSC_VER
1818
#pragma warning(push)
1919
#pragma warning(disable:4127) // Conditional expression is constant
20+
#pragma warning(disable:4100) // unreferenced formal parameter
2021
#endif
2122

2223
///////////////////////////////////////////////////////////////////////////

include/cereal/types/memory.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ namespace cereal
4646
{
4747
PtrWrapper(T && p) : ptr(std::forward<T>(p)) {}
4848
T & ptr;
49+
50+
PtrWrapper & operator=( PtrWrapper const & ) = delete;
4951
};
5052

5153
//! Make a PtrWrapper

0 commit comments

Comments
 (0)