.TH "traits.hpp" 3 "Sat Aug 29 2026 00:42:30" "cereal" \" -*- nroff -*- .ad l .nh .SH NAME traits.hpp \- Internal type trait support\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include 'cereal/macros\&.hpp'\fP .br \fR#include 'cereal/access\&.hpp'\fP .br .SS "Classes" .in +1c .ti -1c .RI "struct \fBcereal::traits::detail::delay_static_assert< T >\fP" .br .RI "Used to delay a static_assert until template instantiation\&. " .ti -1c .RI "struct \fBcereal::traits::detail::meta_bool_and< H, T >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::meta_bool_and< B >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::meta_bool_or< H, T >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::meta_bool_or< B >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::EnableIfHelper< Conditions >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::DisableIfHelper< Conditions >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::get_output_from_input< InputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::get_input_from_output< OutputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_member_save< T, A >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_member_versioned_save< T, A >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::is_string< class >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::is_string< std::basic_string< CharT, Traits, Alloc > >\fP" .br .ti -1c .RI "struct \fBcereal::traits::is_minimal_type< T >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::NoConvertBase\fP" .br .RI "Used to help strip away conversion wrappers\&. " .ti -1c .RI "struct \fBcereal::traits::detail::NoConvertConstRef< Source >\fP" .br .RI "A struct that prevents implicit conversion\&. " .ti -1c .RI "struct \fBcereal::traits::detail::NoConvertRef< Source >\fP" .br .RI "A struct that prevents implicit conversion\&. " .ti -1c .RI "struct \fBcereal::traits::detail::AnyConvert\fP" .br .RI "A type that can implicitly convert to anything else\&. " .ti -1c .RI "struct \fBcereal::traits::detail::has_member_load_and_construct_impl< T, A >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::has_member_versioned_load_and_construct_impl< T, A >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_member_load_and_construct< T, A >\fP" .br .RI "Member load and construct check\&. " .ti -1c .RI "struct \fBcereal::traits::has_member_versioned_load_and_construct< T, A >\fP" .br .RI "Member load and construct check (versioned)\&. " .ti -1c .RI "struct \fBcereal::traits::has_load_and_construct< T, A >\fP" .br .RI "Non member load and construct check\&. " .ti -1c .RI "struct \fBcereal::traits::has_member_split< T, InputArchive, OutputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_non_member_split< T, InputArchive, OutputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_invalid_output_versioning< T, OutputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_invalid_input_versioning< T, InputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::count_specializations< T, A >\fP" .br .RI "Number of specializations detected\&. " .ti -1c .RI "struct \fBcereal::traits::is_specialized< T, A >\fP" .br .RI "Check if any specialization exists for a type\&. " .ti -1c .RI "struct \fBcereal::traits::has_minimal_output_serialization< T, OutputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_minimal_input_serialization< T, InputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::count_output_serializers< T, OutputArchive >\fP" .br .RI "The number of output serialization functions available\&. " .ti -1c .RI "struct \fBcereal::traits::is_output_serializable< T, OutputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::count_input_serializers< T, InputArchive >\fP" .br .RI "The number of input serialization functions available\&. " .ti -1c .RI "struct \fBcereal::traits::is_input_serializable< T, InputArchive >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::base_class_id\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::base_class_id_hash\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::BaseCastBase\fP" .br .RI "Common base type for base class casting\&. " .ti -1c .RI "struct \fBcereal::traits::detail::get_base_class< Cast< Base > >\fP" .br .ti -1c .RI "struct \fBcereal::traits::detail::has_minimal_base_class_serialization_impl< Cast, Test, Archive, IsBaseCast >\fP" .br .RI "Base class cast, behave as the test\&. " .ti -1c .RI "struct \fBcereal::traits::detail::has_minimal_base_class_serialization_impl< Cast, Test, Archive, false >\fP" .br .RI "Not a base class cast\&. " .ti -1c .RI "struct \fBcereal::traits::has_minimal_base_class_serialization< Cast, Test, Archive >\fP" .br .RI "Checks to see if the base class used in a cast has a minimal serialization\&. " .ti -1c .RI "struct \fBcereal::traits::detail::shared_from_this_wrapper\fP" .br .ti -1c .RI "struct \fBcereal::traits::has_shared_from_this< T >\fP" .br .RI "Determine if T or any base class of T has inherited from std::enable_shared_from_this\&. " .ti -1c .RI "struct \fBcereal::traits::get_shared_from_this_base< T >\fP" .br .RI "Get the type of the base class of T which inherited from std::enable_shared_from_this\&. " .ti -1c .RI "struct \fBcereal::traits::strip_minimal< T, IsCerealMinimalTrait >\fP" .br .RI "Extracts the true type from something possibly wrapped in a cereal NoConvert\&. " .ti -1c .RI "struct \fBcereal::traits::strip_minimal< T, true >\fP" .br .RI "Specialization for types wrapped in a NoConvert\&. " .ti -1c .RI "struct \fBcereal::traits::is_default_constructible< T >\fP" .br .RI "Determines whether the class T can be default constructed by \fBcereal::access\fP\&. " .ti -1c .RI "struct \fBcereal::traits::is_same_archive< ArchiveT, CerealArchiveT >\fP" .br .RI "Checks if the provided archive type is equal to some cereal archive type\&. " .ti -1c .RI "struct \fBcereal::traits::TextArchive\fP" .br .RI "Type traits only struct used to mark an archive as human readable (text based)\&. " .ti -1c .RI "struct \fBcereal::traits::is_text_archive< A >\fP" .br .RI "Checks if an archive is a text archive (human readable)\&. " .ti -1c .RI "struct \fBcereal::detail::Construct< T, A, Member, MemberVersioned, NonMember, NonMemberVersioned >\fP" .br .ti -1c .RI "struct \fBcereal::detail::Construct< T, A, false, false, false, false >\fP" .br .ti -1c .RI "struct \fBcereal::detail::Construct< T, A, true, false, false, false >\fP" .br .ti -1c .RI "struct \fBcereal::detail::Construct< T, A, false, true, false, false >\fP" .br .ti -1c .RI "struct \fBcereal::detail::Construct< T, A, false, false, true, false >\fP" .br .ti -1c .RI "struct \fBcereal::detail::Construct< T, A, false, false, false, true >\fP" .br .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBCEREAL_SETUP_ARCHIVE_TRAITS\fP(InputArchive, OutputArchive)" .br .RI "Sets up traits that relate an input archive to an output archive\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_VERSIONED_TEST\fP ,0" .br .RI "Used to convert a MAKE_HAS_XXX macro into a versioned variant\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_TEST\fP(name, test_name, versioned)" .br .RI "Creates a test for whether a non const member function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_NON_MEMBER_TEST\fP(test_name, func, versioned)" .br .RI "Creates a test for whether a non const non-member function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_SAVE_IMPL\fP(test_name, versioned)" .br .RI "Creates a test for whether a member save function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_NON_MEMBER_SAVE_TEST\fP(test_name, versioned)" .br .RI "Creates a test for whether a non-member save function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_SAVE_MINIMAL_IMPL\fP(test_name, versioned)" .br .RI "Creates implementation details for whether a member save_minimal function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_SAVE_MINIMAL_HELPERS_IMPL\fP(test_name, versioned)" .br .RI "Creates helpers for minimal save functions\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_SAVE_MINIMAL_TEST\fP(test_name)" .br .RI "Creates a test for whether a member save_minimal function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_NON_MEMBER_SAVE_MINIMAL_TEST\fP(test_name, versioned)" .br .RI "Creates a test for whether a non-member save_minimal function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_LOAD_MINIMAL_IMPL\fP(test_name, versioned)" .br .RI "Creates a test for whether a member load_minimal function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_LOAD_MINIMAL_HELPERS_IMPL\fP(load_test_name, save_test_name, save_test_prefix, versioned)" .br .RI "Creates helpers for minimal load functions\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_MEMBER_LOAD_MINIMAL_TEST\fP(load_test_name, load_test_prefix)" .br .RI "Creates a test for whether a member load_minimal function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_NON_MEMBER_LOAD_MINIMAL_TEST\fP(test_name, save_name, versioned)" .br .RI "Creates a test for whether a non-member load_minimal function exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_HAS_NON_MEMBER_LOAD_AND_CONSTRUCT_TEST\fP(test_name, versioned)" .br .RI "Creates a test for whether a non-member load_and_construct specialization exists\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_IS_SPECIALIZED_IMPL\fP(name)" .br .RI "Create a test for a cereal::specialization entry\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_IS_SPECIALIZED_ASSERT\fP(name, versioned_name, print_name, spec_name)" .br .RI "Create the static assertion for some specialization\&. " .ti -1c .RI "#define \fBCEREAL_MAKE_IS_SPECIALIZED\fP(name, versioned_name, spec_name)" .br .RI "Generates a test for specialization for versioned and unversioned functions\&. " .ti -1c .RI "#define \fBCEREAL_ARCHIVE_RESTRICT\fP(INTYPE, OUTTYPE)" .br .RI "A macro to use to restrict which types of archives your function will work for\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "using \fBcereal::traits::yes\fP = std::true_type" .br .ti -1c .RI "using \fBcereal::traits::no\fP = std::false_type" .br .ti -1c .RI "template using \fBEnableIf\fP = typename detail::EnableIfHelper::type" .br .RI "Provides a way to enable a function if conditions are met\&. " .ti -1c .RI "template using \fBDisableIf\fP = typename detail::DisableIfHelper::type" .br .RI "Provides a way to disable a function if conditions are met\&. " .ti -1c .RI "template using \fBcereal::traits::detail::decay_archive\fP = typename std::decay::type>::type" .br .RI "Removes all qualifiers and minimal wrappers from an archive\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum class \fBcereal::traits::detail::sfinae\fP " .br .RI "Return type for SFINAE Enablers\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_MEMBER_TEST\fP (\fBserialize\fP, \fBserialize\fP,)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_MEMBER_TEST\fP (\fBserialize\fP, versioned_serialize, \fBCEREAL_MAKE_VERSIONED_TEST\fP)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_NON_MEMBER_TEST\fP (\fBserialize\fP, \fBCEREAL_SERIALIZE_FUNCTION_NAME\fP,)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_NON_MEMBER_TEST\fP (versioned_serialize, \fBCEREAL_SERIALIZE_FUNCTION_NAME\fP, \fBCEREAL_MAKE_VERSIONED_TEST\fP)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_MEMBER_TEST\fP (load, load,)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_MEMBER_TEST\fP (load, versioned_load, \fBCEREAL_MAKE_VERSIONED_TEST\fP)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_NON_MEMBER_TEST\fP (load, \fBCEREAL_LOAD_FUNCTION_NAME\fP,)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_HAS_NON_MEMBER_TEST\fP (versioned_load, \fBCEREAL_LOAD_FUNCTION_NAME\fP, \fBCEREAL_MAKE_VERSIONED_TEST\fP)" .br .ti -1c .RI "\fBcereal::traits::detail::CEREAL_MAKE_IS_SPECIALIZED_IMPL\fP (member_serialize)" .br .ti -1c .RI "\fBcereal::traits::detail::CEREAL_MAKE_IS_SPECIALIZED_IMPL\fP (member_load_save)" .br .ti -1c .RI "\fBcereal::traits::detail::CEREAL_MAKE_IS_SPECIALIZED_IMPL\fP (member_load_save_minimal)" .br .ti -1c .RI "\fBcereal::traits::detail::CEREAL_MAKE_IS_SPECIALIZED_IMPL\fP (non_member_serialize)" .br .ti -1c .RI "\fBcereal::traits::detail::CEREAL_MAKE_IS_SPECIALIZED_IMPL\fP (non_member_load_save)" .br .ti -1c .RI "\fBcereal::traits::detail::CEREAL_MAKE_IS_SPECIALIZED_IMPL\fP (non_member_load_save_minimal)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (member_serialize, member_versioned_serialize, member_serialize)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (non_member_serialize, non_member_versioned_serialize, non_member_serialize)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (member_save, member_versioned_save, member_load_save)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (non_member_save, non_member_versioned_save, non_member_load_save)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (member_load, member_versioned_load, member_load_save)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (non_member_load, non_member_versioned_load, non_member_load_save)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (member_save_minimal, member_versioned_save_minimal, member_load_save_minimal)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (non_member_save_minimal, non_member_versioned_save_minimal, non_member_load_save_minimal)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (member_load_minimal, member_versioned_load_minimal, member_load_save_minimal)" .br .ti -1c .RI "\fBcereal::traits::CEREAL_MAKE_IS_SPECIALIZED\fP (non_member_load_minimal, non_member_versioned_load_minimal, non_member_load_save_minimal)" .br .in -1c .SH "Detailed Description" .PP Internal type trait support\&. .SH "Macro Definition Documentation" .PP .SS "#define CEREAL_ARCHIVE_RESTRICT( INTYPE, OUTTYPE)" \fBValue:\fP .nf typename std::enable_if::value || cereal::traits::is_same_archive::value, void>::type .PP .fi .PP A macro to use to restrict which types of archives your function will work for\&. This requires you to have a template class parameter named Archive and replaces the void return type for your function\&. .PP INTYPE refers to the input archive type you wish to restrict on\&. OUTTYPE refers to the output archive type you wish to restrict on\&. .PP For example, if we want to limit a serialize to only work with binary serialization: .PP .PP .nf template CEREAL_ARCHIVE_RESTRICT(BinaryInputArchive, BinaryOutputArchive) serialize( Archive & ar, MyCoolType & m ) { ar & m; } .fi .PP .PP If you need to do more restrictions in your enable_if, you will need to do this by hand\&. .SS "#define CEREAL_MAKE_HAS_MEMBER_LOAD_MINIMAL_HELPERS_IMPL( load_test_name, save_test_name, save_test_prefix, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_member_##load_test_name##_wrapper : std::false_type {}; \\ \\ template \\ struct has_member_##load_test_name##_wrapper \\ { \\ using AOut = typename detail::get_output_from_input::type; \\ \\ static_assert( has_member_##save_test_prefix##_minimal::value, \\ "cereal detected member " #load_test_name " but no valid member " #save_test_name "\&. \\n " \\ "cannot evaluate correctness of " #load_test_name " without valid " #save_test_name "\&." ); \\ \\ using SaveType = typename detail::get_member_##save_test_prefix##_minimal_type::type; \\ const static bool value = has_member_##load_test_name##_impl::value; \\ const static bool valid = has_member_##load_test_name##_type_impl::value; \\ \\ static_assert( valid || !value, "cereal detected different or invalid types in corresponding member " \\ #load_test_name " and " #save_test_name " functions\&. \\n " \\ "the paramater to " #load_test_name " must be a constant reference to the type that " \\ #save_test_name " returns\&." ); \\ }; \\ } .PP .fi .PP Creates helpers for minimal load functions\&. The has_member_*_wrapper structs ensure that the load and save types for the requested function type match appropriately\&. .PP \fBParameters\fP .RS 4 \fIload_test_name\fP The name to give the test (e\&.g\&. load_minimal or versioned_load_minimal) .br \fIsave_test_name\fP The name to give the test (e\&.g\&. save_minimal or versioned_save_minimal, should match the load name\&. .br \fIsave_test_prefix\fP The name to give the test (e\&.g\&. save_minimal or versioned_save_minimal, should match the load name, without the trailing "_minimal" (e\&.g\&. save or versioned_save)\&. Needed because the preprocessor is an abomination\&. .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_LOAD_MINIMAL_IMPL( test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_member_##test_name##_impl \\ { \\ template \\ static auto test(int) \-> decltype( cereal::access::member_load_minimal( \\ std::declval(), \\ std::declval(), AnyConvert() versioned ), yes()); \\ template static no test(\&.\&.\&.); \\ static const bool value = std::is_same(0)), yes>::value; \\ }; \\ template \\ struct has_member_##test_name##_type_impl \\ { \\ template \\ static auto test(int) \-> decltype( cereal::access::member_load_minimal( \\ std::declval(), \\ std::declval(), NoConvertConstRef() versioned ), yes()); \\ template static no test(\&.\&.\&.); \\ static const bool value = std::is_same(0)), yes>::value; \\ \\ }; \\ } .PP .fi .PP Creates a test for whether a member load_minimal function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP Our strategy here is to first check if a function matching the signature more or less exists (allow anything like load_minimal(xxx) using AnyConvert, and then secondly enforce that it has the correct signature using NoConvertConstRef .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. load_minimal or versioned_load_minimal) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_LOAD_MINIMAL_TEST( load_test_name, load_test_prefix)" \fBValue:\fP .nf template \\ struct has_member_##load_test_prefix##_minimal : std::integral_constant::value>::value> {}; .PP .fi .PP Creates a test for whether a member load_minimal function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fIload_test_name\fP The name to give the test (e\&.g\&. load_minimal or versioned_load_minimal) .br \fIload_test_prefix\fP The above parameter minus the trailing "_minimal" .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_SAVE_IMPL( test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_member_##test_name##_impl \\ { \\ template \\ static auto test(int) \-> decltype( cereal::access::member_save( std::declval(), \\ std::declval() versioned ), yes()); \\ template static no test(\&.\&.\&.); \\ static const bool value = std::is_same(0)), yes>::value; \\ \\ template \\ static auto test2(int) \-> decltype( cereal::access::member_save_non_const( \\ std::declval(), \\ std::declval::type&>() versioned ), yes()); \\ template static no test2(\&.\&.\&.); \\ static const bool not_const_type = std::is_same(0)), yes>::value; \\ }; \\ } .PP .fi .PP Creates a test for whether a member save function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. save or versioned_save) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_SAVE_MINIMAL_HELPERS_IMPL( test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct get_member_##test_name##_type { using type = void; }; \\ \\ template \\ struct get_member_##test_name##_type \\ { \\ using type = decltype( cereal::access::member_save_minimal( std::declval(), \\ std::declval() versioned ) ); \\ }; \\ } .PP .fi .PP Creates helpers for minimal save functions\&. The get_member_*_type structs allow access to the return type of a save_minimal, assuming that the function actually exists\&. If the function does not exist, the type will be void\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. save_minimal or versioned_save_minimal) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_SAVE_MINIMAL_IMPL( test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_member_##test_name##_impl \\ { \\ template \\ static auto test(int) \-> decltype( cereal::access::member_save_minimal( \\ std::declval(), \\ std::declval() versioned ), yes()); \\ template static no test(\&.\&.\&.); \\ static const bool value = std::is_same(0)), yes>::value; \\ \\ template \\ static auto test2(int) \-> decltype( cereal::access::member_save_minimal_non_const( \\ std::declval(), \\ std::declval::type&>() versioned ), yes()); \\ template static no test2(\&.\&.\&.); \\ static const bool not_const_type = std::is_same(0)), yes>::value; \\ \\ static const bool valid = value || !not_const_type; \\ }; \\ } .PP .fi .PP Creates implementation details for whether a member save_minimal function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. save_minimal or versioned_save_minimal) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_SAVE_MINIMAL_TEST( test_name)" \fBValue:\fP .nf template \\ struct has_member_##test_name : std::integral_constant::value> \\ { \\ using check = typename detail::has_member_##test_name##_impl; \\ static_assert( check::valid, \\ "cereal detected a non\-const member " #test_name "\&. \\n " \\ #test_name " member functions must always be const" ); \\ \\ using type = typename detail::get_member_##test_name##_type::type; \\ static_assert( (check::value && is_minimal_type::value) || !check::value, \\ "cereal detected a member " #test_name " with an invalid return type\&. \\n " \\ "return type must be arithmetic or string" ); \\ }; .PP .fi .PP Creates a test for whether a member save_minimal function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. save_minimal or versioned_save_minimal) .RE .PP .SS "#define CEREAL_MAKE_HAS_MEMBER_TEST( name, test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_member_##name##_##versioned##_impl \\ { \\ template \\ static auto test(int) \-> decltype( cereal::access::member_##name( std::declval(), std::declval() versioned ), yes()); \\ template \\ static no test(\&.\&.\&.); \\ static const bool value = std::is_same(0)), yes>::value; \\ }; \\ } \\ template \\ struct has_member_##test_name : std::integral_constant::value> {} .PP .fi .PP Creates a test for whether a non const member function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fIname\fP The name of the function to test for (e\&.g\&. serialize, load, save) .br \fItest_name\fP The name to give the test for the function being tested for (e\&.g\&. serialize, versioned_serialize) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_NON_MEMBER_LOAD_AND_CONSTRUCT_TEST( test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_non_member_##test_name##_impl \\ { \\ template \\ static auto test(int) \-> decltype( LoadAndConstruct::load_and_construct( \\ std::declval(), std::declval< ::cereal::construct&>() versioned ), yes()); \\ template \\ static no test( \&.\&.\&. ); \\ static const bool value = std::is_same( 0 ) ), yes>::value; \\ }; \\ } \\ template \\ struct has_non_member_##test_name : \\ std::integral_constant::type, A>::value> {}; .PP .fi .PP Creates a test for whether a non-member load_and_construct specialization exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper non-member function for the given archive\&. .SS "#define CEREAL_MAKE_HAS_NON_MEMBER_LOAD_MINIMAL_TEST( test_name, save_name, versioned)" .PP Creates a test for whether a non-member load_minimal function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP See notes from member load_minimal implementation\&. .PP Note that there should be an additional const check on load_minimal after the valid check, but this currently interferes with many valid uses of minimal serialization\&. It has been removed (see #565 on github) and previously was: .PP .PP .nf static_assert( check::const_valid || !check::exists, "cereal detected an invalid serialization type parameter in non\-member " #test_name "\&. " #test_name " non\-member functions must accept their serialization type by non\-const reference" ); .fi .PP .PP See #132, #436, #263, and #565 on https://github.com/USCiLab/cereal for more details\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. load_minimal or versioned_load_minimal) .br \fIsave_name\fP The corresponding name the save test would have (e\&.g\&. save_minimal or versioned_save_minimal) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_NON_MEMBER_SAVE_MINIMAL_TEST( test_name, versioned)" .PP Creates a test for whether a non-member save_minimal function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. save_minimal or versioned_save_minimal) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_NON_MEMBER_SAVE_TEST( test_name, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_non_member_##test_name##_impl \\ { \\ template \\ static auto test(int) \-> decltype( CEREAL_SAVE_FUNCTION_NAME( \\ std::declval(), \\ std::declval() versioned ), yes()); \\ template static no test(\&.\&.\&.); \\ static const bool value = std::is_same(0)), yes>::value; \\ \\ template \\ static auto test2(int) \-> decltype( CEREAL_SAVE_FUNCTION_NAME( \\ std::declval(), \\ std::declval::type&>() versioned ), yes()); \\ template static no test2(\&.\&.\&.); \\ static const bool not_const_type = std::is_same(0)), yes>::value; \\ }; \\ } \\ \\ template \\ struct has_non_member_##test_name : std::integral_constant::value> \\ { \\ using check = typename detail::has_non_member_##test_name##_impl; \\ static_assert( check::value || !check::not_const_type, \\ "cereal detected a non\-const type parameter in non\-member " #test_name "\&. \\n " \\ #test_name " non\-member functions must always pass their types as const" ); \\ }; .PP .fi .PP Creates a test for whether a non-member save function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper non-member function for the given archive\&. .PP \fBParameters\fP .RS 4 \fItest_name\fP The name to give the test (e\&.g\&. save or versioned_save) .br \fIversioned\fP Either blank or the macro CEREAL_MAKE_VERSIONED_TEST .RE .PP .SS "#define CEREAL_MAKE_HAS_NON_MEMBER_TEST( test_name, func, versioned)" \fBValue:\fP .nf namespace detail \\ { \\ template \\ struct has_non_member_##test_name##_impl \\ { \\ template \\ static auto test(int) \-> decltype( func( std::declval(), std::declval() versioned ), yes()); \\ template \\ static no test( \&.\&.\&. ); \\ static const bool value = std::is_same( 0 ) ), yes>::value; \\ }; \\ } \\ template \\ struct has_non_member_##test_name : std::integral_constant::value> {} .PP .fi .PP Creates a test for whether a non const non-member function exists\&. This creates a class derived from std::integral_constant that will be true if the type has the proper non-member function for the given archive\&. .SS "#define CEREAL_MAKE_IS_SPECIALIZED( name, versioned_name, spec_name)" \fBValue:\fP .nf template \\ struct is_specialized_##name : std::integral_constant::value && detail::is_specialized_##spec_name::value> \\ { CEREAL_MAKE_IS_SPECIALIZED_ASSERT(name, versioned_name, name, spec_name); }; \\ template \\ struct is_specialized_##versioned_name : std::integral_constant::value && detail::is_specialized_##spec_name::value> \\ { CEREAL_MAKE_IS_SPECIALIZED_ASSERT(name, versioned_name, versioned_name, spec_name); } .PP .fi .PP Generates a test for specialization for versioned and unversioned functions\&. This creates checks that can be queried to see if a given type of serialization function has been specialized for this type .SS "#define CEREAL_MAKE_IS_SPECIALIZED_ASSERT( name, versioned_name, print_name, spec_name)" \fBValue:\fP .nf static_assert( (is_specialized::value && detail::is_specialized_##spec_name::value && \\ (has_##name::value || has_##versioned_name::value)) \\ || !(is_specialized::value && detail::is_specialized_##spec_name::value), \\ "cereal detected " #print_name " specialization but no " #print_name " serialize function" ) .PP .fi .PP Create the static assertion for some specialization\&. This assertion will fail if the type is indeed specialized and does not have the appropriate type of serialization functions .SS "#define CEREAL_MAKE_IS_SPECIALIZED_IMPL( name)" \fBValue:\fP .nf template \\ struct is_specialized_##name : std::integral_constant>::value> {} .PP .fi .PP Create a test for a cereal::specialization entry\&. .SS "#define CEREAL_SETUP_ARCHIVE_TRAITS( InputArchive, OutputArchive)" \fBValue:\fP .nf namespace cereal { namespace traits { namespace detail { \\ template <> struct get_output_from_input \\ { using type = OutputArchive; }; \\ template <> struct get_input_from_output \\ { using type = InputArchive; }; } } } .PP .fi .PP Sets up traits that relate an input archive to an output archive\&. .SH "Typedef Documentation" .PP .SS "template using \fBDisableIf\fP = typename detail::DisableIfHelper::type" .PP Provides a way to disable a function if conditions are met\&. This is intended to be used in a near identical fashion to std::enable_if while being significantly easier to read at the cost of not allowing for as complicated of a condition\&. .PP This will compile (allow the function) if every condition evaluates to false\&. This should be used with SFINAE to ensure that at least one other candidate function works when one fails due to a \fBDisableIf\fP\&. .PP This should be used as the las template parameter to a function as an unnamed parameter with a default value of cereal::traits::sfinae: .PP .PP .nf // using by making the last template argument variadic template ::value> = sfinae> void func(T t ); .fi .PP .PP This is often used in conjunction with \fBEnableIf\fP to form an enable/disable pair of overloads\&. .PP Note that this performs a logical AND of all conditions, so you will need to construct more complicated requirements with this fact in mind\&. If all conditions hold, the function will be disabled\&. .PP \fBTemplate Parameters\fP .RS 4 \fIConditions\fP The conditions which will be logically ANDed to disable the function\&. .RE .PP .SS "template using \fBEnableIf\fP = typename detail::EnableIfHelper::type" .PP Provides a way to enable a function if conditions are met\&. This is intended to be used in a near identical fashion to std::enable_if while being significantly easier to read at the cost of not allowing for as complicated of a condition\&. .PP This will compile (allow the function) if every condition evaluates to true\&. at compile time\&. This should be used with SFINAE to ensure that at least one other candidate function works when one fails due to an \fBEnableIf\fP\&. .PP This should be used as the las template parameter to a function as an unnamed parameter with a default value of cereal::traits::sfinae: .PP .PP .nf // using by making the last template argument variadic template ::value> = sfinae> void func(T t ); .fi .PP .PP Note that this performs a logical AND of all conditions, so you will need to construct more complicated requirements with this fact in mind\&. .PP \fBTemplate Parameters\fP .RS 4 \fIConditions\fP The conditions which will be logically ANDed to enable the function\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for cereal from the source code\&.