Commit 2e8505ff authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'bp_cereal' into 'v2.3-stable'

[v2.3-stable] Update Cereal to 1.3.2

See merge request allpix-squared/allpix-squared!768
parents 30e3b965 d466ee32
Loading
Loading
Loading
Loading
+284 −291
Original line number Diff line number Diff line
@@ -11,14 +11,14 @@
      * Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
      * Neither the name of cereal nor the
      * Neither the name of the copyright holder nor the
        names of its contributors may be used to endorse or promote products
        derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -29,16 +29,17 @@
#ifndef CEREAL_ACCESS_HPP_
#define CEREAL_ACCESS_HPP_

#include <type_traits>
#include <iostream>
#include <cstdint>
#include <functional>
#include <iostream>
#include <type_traits>

#include "cereal/details/helpers.hpp"
#include "cereal/macros.hpp"
#include "cereal/specialize.hpp"
#include "cereal/details/helpers.hpp"

namespace cereal {
namespace cereal
{
  // ######################################################################
  //! A class that allows cereal to load smart pointers to types that have no default constructor
  /*! If your class does not have a default constructor, cereal will not be able
@@ -103,16 +104,14 @@ namespace cereal {

      @tparam T The type to specialize for
      @ingroup Access */
    template <class T> struct LoadAndConstruct {};
  template <class T>
  struct LoadAndConstruct
  { };

  // forward decl for construct
  //! @cond PRIVATE_NEVERDEFINED
    namespace memory_detail {
        template <class Ar, class T> struct LoadAndConstructLoadWrapper;
    }
    namespace boost_variant_detail {
        template <class Ar, class T> struct LoadAndConstructLoadWrapper;
    }
  namespace memory_detail{ template <class Ar, class T> struct LoadAndConstructLoadWrapper; }
  namespace boost_variant_detail{ template <class Ar, class T> struct LoadAndConstructLoadWrapper; }
  //! @endcond

  //! Used to construct types with no default constructor
@@ -161,7 +160,9 @@ namespace cereal {

      @tparam T The class type being serialized
      */
    template <class T> class construct {
  template <class T>
  class construct
  {
    public:
      //! Construct and initialize the type T with the given arguments
      /*! This will forward all arguments to the underlying type T,
@@ -172,7 +173,8 @@ namespace cereal {

          @param args The arguments to the constructor for T
          @throw Exception If called more than once */
        template <class... Args> void operator()(Args&&... args);
      template <class ... Args>
      void operator()( Args && ... args );
      // implementation deferred due to reliance on cereal::access

      //! Get a reference to the initialized underlying object
@@ -180,7 +182,8 @@ namespace cereal {

          @return A reference to the initialized object
          @throw Exception If called before initialization */
        T* operator->() {
      T * operator->()
      {
        if( !itsValid )
          throw Exception("Object must be initialized prior to accessing members");

@@ -195,15 +198,17 @@ namespace cereal {
          any other circumstance.

          @return A raw pointer to the initialized type */
        T* ptr() { return operator->(); }
      T * ptr()
      {
        return operator->();
      }

    private:
      template <class Ar, class TT> friend struct ::cereal::memory_detail::LoadAndConstructLoadWrapper;
      template <class Ar, class TT> friend struct ::cereal::boost_variant_detail::LoadAndConstructLoadWrapper;

      construct( T * p ) : itsPtr( p ), itsEnableSharedRestoreFunction( [](){} ), itsValid( false ) {}
        construct(T* p, std::function<void()> enableSharedFunc)
            : // g++4.7 ice with default lambda to std func
      construct( T * p, std::function<void()> enableSharedFunc ) : // g++4.7 ice with default lambda to std func
        itsPtr( p ), itsEnableSharedRestoreFunction( enableSharedFunc ), itsValid( false ) {}
      construct( construct const & ) = delete;
      construct & operator=( construct const & ) = delete;
@@ -232,120 +237,108 @@ namespace cereal {
      };
      @endcode
      @ingroup Access */
    class access {
  class access
  {
    public:
      // ####### Standard Serialization ########################################
        template <class Archive, class T>
        inline static auto member_serialize(Archive& ar, T& t) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar)) {
            return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar);
        }
      template<class Archive, class T> inline
      static auto member_serialize(Archive & ar, T & t) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar))
      { return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar); }

        template <class Archive, class T>
        inline static auto member_save(Archive& ar, T const& t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar)) {
            return t.CEREAL_SAVE_FUNCTION_NAME(ar);
        }
      template<class Archive, class T> inline
      static auto member_save(Archive & ar, T const & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
      { return t.CEREAL_SAVE_FUNCTION_NAME(ar); }

        template <class Archive, class T>
        inline static auto member_save_non_const(Archive& ar, T& t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar)) {
            return t.CEREAL_SAVE_FUNCTION_NAME(ar);
        }
      template<class Archive, class T> inline
      static auto member_save_non_const(Archive & ar, T & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
      { return t.CEREAL_SAVE_FUNCTION_NAME(ar); }

        template <class Archive, class T>
        inline static auto member_load(Archive& ar, T& t) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar)) {
            return t.CEREAL_LOAD_FUNCTION_NAME(ar);
        }
      template<class Archive, class T> inline
      static auto member_load(Archive & ar, T & t) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar))
      { return t.CEREAL_LOAD_FUNCTION_NAME(ar); }

        template <class Archive, class T>
        inline static auto member_save_minimal(Archive const& ar, T const& t)
            -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar)) {
            return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar);
        }
      template<class Archive, class T> inline
      static auto member_save_minimal(Archive const & ar, T const & t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
      { return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar); }

        template <class Archive, class T>
        inline static auto member_save_minimal_non_const(Archive const& ar, T& t)
            -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar)) {
            return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar);
        }
      template<class Archive, class T> inline
      static auto member_save_minimal_non_const(Archive const & ar, T & t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
      { return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar); }

        template <class Archive, class T, class U>
        inline static auto member_load_minimal(Archive const& ar, T& t, U&& u)
            -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u))) {
            return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u));
        }
      template<class Archive, class T, class U> inline
      static auto member_load_minimal(Archive const & ar, T & t, U && u) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u)))
      { return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u)); }

      // ####### Versioned Serialization #######################################
        template <class Archive, class T>
        inline static auto member_serialize(Archive& ar, T& t, const std::uint32_t version)
            -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version)) {
            return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version);
        }
      template<class Archive, class T> inline
      static auto member_serialize(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version))
      { return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version); }

        template <class Archive, class T>
        inline static auto member_save(Archive& ar, T const& t, const std::uint32_t version)
            -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version)) {
            return t.CEREAL_SAVE_FUNCTION_NAME(ar, version);
        }
      template<class Archive, class T> inline
      static auto member_save(Archive & ar, T const & t, const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
      { return t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }

        template <class Archive, class T>
        inline static auto member_save_non_const(Archive& ar, T& t, const std::uint32_t version)
            -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version)) {
            return t.CEREAL_SAVE_FUNCTION_NAME(ar, version);
        }
      template<class Archive, class T> inline
      static auto member_save_non_const(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
      { return t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }

        template <class Archive, class T>
        inline static auto member_load(Archive& ar, T& t, const std::uint32_t version)
            -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar, version)) {
            return t.CEREAL_LOAD_FUNCTION_NAME(ar, version);
        }
      template<class Archive, class T> inline
      static auto member_load(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar, version))
      { return t.CEREAL_LOAD_FUNCTION_NAME(ar, version); }

        template <class Archive, class T>
        inline static auto member_save_minimal(Archive const& ar, T const& t, const std::uint32_t version)
            -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version)) {
            return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version);
        }
      template<class Archive, class T> inline
      static auto member_save_minimal(Archive const & ar, T const & t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version))
      { return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version); }

        template <class Archive, class T>
        inline static auto member_save_minimal_non_const(Archive const& ar, T& t, const std::uint32_t version)
            -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version)) {
            return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version);
        }
      template<class Archive, class T> inline
      static auto member_save_minimal_non_const(Archive const & ar, T & t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version))
      { return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version); }

        template <class Archive, class T, class U>
        inline static auto member_load_minimal(Archive const& ar, T& t, U&& u, const std::uint32_t version)
            -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version)) {
            return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version);
        }
      template<class Archive, class T, class U> inline
      static auto member_load_minimal(Archive const & ar, T & t, U && u, const std::uint32_t version) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version))
      { return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version); }

      // ####### Other Functionality ##########################################
      // for detecting inheritance from enable_shared_from_this
        template <class T> inline static auto shared_from_this(T& t) -> decltype(t.shared_from_this());
      template <class T> inline
      static auto shared_from_this(T & t) -> decltype(t.shared_from_this());

      // for placement new
        template <class T, class... Args> inline static void construct(T*& ptr, Args&&... args) {
      template <class T, class ... Args> inline
      static void construct( T *& ptr, Args && ... args )
      {
        new (ptr) T( std::forward<Args>( args )... );
      }

      // for non-placement new with a default constructor
        template <class T> inline static T* construct() { return new T(); }
      template <class T> inline
      static T * construct()
      {
        return new T();
      }

        template <class T> inline static std::false_type load_and_construct(...) { return std::false_type(); }
      template <class T> inline
      static std::false_type load_and_construct(...)
      { return std::false_type(); }

        template <class T, class Archive>
        inline static auto load_and_construct(Archive& ar, ::cereal::construct<T>& construct)
            -> decltype(T::load_and_construct(ar, construct)) {
      template<class T, class Archive> inline
      static auto load_and_construct(Archive & ar, ::cereal::construct<T> & construct) -> decltype(T::load_and_construct(ar, construct))
      {
        T::load_and_construct( ar, construct );
      }

        template <class T, class Archive>
        inline static auto load_and_construct(Archive& ar, ::cereal::construct<T>& construct, const std::uint32_t version)
            -> decltype(T::load_and_construct(ar, construct, version)) {
      template<class T, class Archive> inline
      static auto load_and_construct(Archive & ar, ::cereal::construct<T> & construct, const std::uint32_t version) -> decltype(T::load_and_construct(ar, construct, version))
      {
        T::load_and_construct( ar, construct, version );
      }
  }; // end class access

  // ######################################################################
  // Deferred Implementation, see construct for more information
    template <class T> template <class... Args> inline void construct<T>::operator()(Args&&... args) {
  template <class T> template <class ... Args> inline
  void construct<T>::operator()( Args && ... args )
  {
    if( itsValid )
      throw Exception("Attempting to construct an already initialized object");

+264 −235

File changed.

Preview size limit exceeded, changes collapsed.

+1040 −898

File changed.

Preview size limit exceeded, changes collapsed.

+356 −321
Original line number Diff line number Diff line
@@ -12,14 +12,14 @@
      * Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
      * Neither the name of cereal nor the
      * Neither the name of the copyright holder nor the
        names of its contributors may be used to endorse or promote products
        derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -30,21 +30,23 @@
#ifndef CEREAL_DETAILS_HELPERS_HPP_
#define CEREAL_DETAILS_HELPERS_HPP_

#include <type_traits>
#include <cstdint>
#include <utility>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <stdexcept>

#include "cereal/details/static_object.hpp"
#include "cereal/macros.hpp"
#include "cereal/details/static_object.hpp"

namespace cereal {
namespace cereal
{
  // ######################################################################
  //! An exception class thrown when things go wrong at runtime
  /*! @ingroup Utility */
    struct Exception : public std::runtime_error {
  struct Exception : public std::runtime_error
  {
    explicit Exception( const std::string & what_ ) : std::runtime_error(what_) {}
    explicit Exception( const char * what_ ) : std::runtime_error(what_) {}
  };
@@ -63,10 +65,11 @@ namespace cereal {
  class BinaryInputArchive;

  // ######################################################################
    namespace detail {
  namespace detail
  {
    struct NameValuePairCore {}; //!< Traits struct for NVPs
    struct DeferredDataCore {}; //!< Traits struct for DeferredData
    }                                // namespace detail
  }

  // ######################################################################
  //! For holding name value pairs
@@ -132,17 +135,21 @@ namespace cereal {
      explicitly control whether they want to use NVPs or not.

      @internal */
    template <class T> class NameValuePair : detail::NameValuePairCore {
  template <class T>
  class NameValuePair : detail::NameValuePairCore
  {
    private:
      // If we get passed an array, keep the type as is, otherwise store
      // a reference if we were passed an l value reference, else copy the value
        using Type = typename std::conditional<
            std::is_array<typename std::remove_reference<T>::type>::value,
      using Type = typename std::conditional<std::is_array<typename std::remove_reference<T>::type>::value,
                                             typename std::remove_cv<T>::type,
            typename std::conditional<std::is_lvalue_reference<T>::value, T, typename std::decay<T>::type>::type>::type;
                                             typename std::conditional<std::is_lvalue_reference<T>::value,
                                                                       T,
                                                                       typename std::decay<T>::type>::type>::type;

      // prevent nested nvps
        static_assert(!std::is_base_of<detail::NameValuePairCore, T>::value, "Cannot pair a name to a NameValuePair");
      static_assert( !std::is_base_of<detail::NameValuePairCore, T>::value,
                     "Cannot pair a name to a NameValuePair" );

      NameValuePair & operator=( NameValuePair const & ) = delete;

@@ -164,22 +171,26 @@ namespace cereal {
  //! A specialization of make_nvp<> that simply forwards the value for binary archives
  /*! @relates NameValuePair
      @internal */
    template <class Archive, class T>
    inline typename std::enable_if<std::is_same<Archive, ::cereal::BinaryInputArchive>::value ||
  template<class Archive, class T> inline
  typename
  std::enable_if<std::is_same<Archive, ::cereal::BinaryInputArchive>::value ||
                 std::is_same<Archive, ::cereal::BinaryOutputArchive>::value,
  T && >::type
    make_nvp(const char*, T&& value) {
  make_nvp( const char *, T && value )
  {
    return std::forward<T>(value);
  }

  //! A specialization of make_nvp<> that actually creates an nvp for non-binary archives
  /*! @relates NameValuePair
      @internal */
    template <class Archive, class T>
    inline typename std::enable_if<!std::is_same<Archive, ::cereal::BinaryInputArchive>::value &&
  template<class Archive, class T> inline
  typename
  std::enable_if<!std::is_same<Archive, ::cereal::BinaryInputArchive>::value &&
                 !std::is_same<Archive, ::cereal::BinaryOutputArchive>::value,
  NameValuePair<T> >::type
    make_nvp(const char* name, T&& value) {
  make_nvp( const char * name, T && value)
  {
    return {name, std::forward<T>(value)};
  }

@@ -196,11 +207,12 @@ namespace cereal {
      best represent this during serialization.

      @internal */
    template <class T> struct BinaryData {
  template <class T>
  struct BinaryData
  {
    //! Internally store the pointer as a void *, keeping const if created with
    //! a const pointer
        using PT = typename std::conditional<
            std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value,
    using PT = typename std::conditional<std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value,
                                         const void *,
                                         void *>::type;

@@ -216,17 +228,21 @@ namespace cereal {
      any data not wrapped in this class.

      @internal */
    template <class T> class DeferredData : detail::DeferredDataCore {
  template <class T>
  class DeferredData : detail::DeferredDataCore
  {
    private:
      // If we get passed an array, keep the type as is, otherwise store
      // a reference if we were passed an l value reference, else copy the value
        using Type = typename std::conditional<
            std::is_array<typename std::remove_reference<T>::type>::value,
      using Type = typename std::conditional<std::is_array<typename std::remove_reference<T>::type>::value,
                                             typename std::remove_cv<T>::type,
            typename std::conditional<std::is_lvalue_reference<T>::value, T, typename std::decay<T>::type>::type>::type;
                                             typename std::conditional<std::is_lvalue_reference<T>::value,
                                                                       T,
                                                                       typename std::decay<T>::type>::type>::type;

      // prevent nested nvps
        static_assert(!std::is_base_of<detail::DeferredDataCore, T>::value, "Cannot defer DeferredData");
      static_assert( !std::is_base_of<detail::DeferredDataCore, T>::value,
                     "Cannot defer DeferredData" );

      DeferredData & operator=( DeferredData const & ) = delete;

@@ -244,12 +260,14 @@ namespace cereal {
  };

  // ######################################################################
    namespace detail {
  namespace detail
  {
    // base classes for type checking
    /* The rtti virtual function only exists to enable an archive to
       be used in a polymorphic fashion, if necessary.  See the
       archive adapters for an example of this */
        class OutputArchiveBase {
    class OutputArchiveBase
    {
      public:
        OutputArchiveBase() = default;
        OutputArchiveBase( OutputArchiveBase && ) CEREAL_NOEXCEPT {}
@@ -260,7 +278,8 @@ namespace cereal {
        virtual void rtti() {}
    };

        class InputArchiveBase {
    class InputArchiveBase
    {
      public:
        InputArchiveBase() = default;
        InputArchiveBase( InputArchiveBase && ) CEREAL_NOEXCEPT {}
@@ -278,7 +297,7 @@ namespace cereal {
    // used during saving pointers
    static const uint32_t msb_32bit  = 0x80000000;
    static const int32_t msb2_32bit = 0x40000000;
    } // namespace detail
  }

  // ######################################################################
  //! A wrapper around size metadata
@@ -289,11 +308,15 @@ namespace cereal {
      your archive and SizeTags allows you to choose what happens.

      @internal */
    template <class T> class SizeTag {
  template <class T>
  class SizeTag
  {
    private:
      // Store a reference if passed an lvalue reference, otherwise
      // make a copy of the data
        using Type = typename std::conditional<std::is_lvalue_reference<T>::value, T, typename std::decay<T>::type>::type;
      using Type = typename std::conditional<std::is_lvalue_reference<T>::value,
                                             T,
                                             typename std::decay<T>::type>::type;

      SizeTag & operator=( SizeTag const & ) = delete;

@@ -324,12 +347,18 @@ namespace cereal {

      \sa make_map_item
      @internal */
    template <class Key, class Value> struct MapItem {
        using KeyType =
            typename std::conditional<std::is_lvalue_reference<Key>::value, Key, typename std::decay<Key>::type>::type;
  template <class Key, class Value>
  struct MapItem
  {
    using KeyType = typename std::conditional<
      std::is_lvalue_reference<Key>::value,
      Key,
      typename std::decay<Key>::type>::type;

        using ValueType =
            typename std::conditional<std::is_lvalue_reference<Value>::value, Value, typename std::decay<Value>::type>::type;
    using ValueType = typename std::conditional<
      std::is_lvalue_reference<Value>::value,
      Value,
      typename std::decay<Value>::type>::type;

    //! Construct a MapItem from a key and a value
    /*! @internal */
@@ -341,42 +370,48 @@ namespace cereal {
    ValueType value;

    //! Serialize the MapItem with the NVPs "key" and "value"
        template <class Archive> inline void CEREAL_SERIALIZE_FUNCTION_NAME(Archive& archive) {
            archive(make_nvp<Archive>("key", key), make_nvp<Archive>("value", value));
    template <class Archive> inline
    void CEREAL_SERIALIZE_FUNCTION_NAME(Archive & archive)
    {
      archive( make_nvp<Archive>("key",   key),
               make_nvp<Archive>("value", value) );
    }
  };

  //! Create a MapItem so that human readable archives will group keys and values together
  /*! @internal
      @relates MapItem */
    template <class KeyType, class ValueType>
    inline MapItem<KeyType, ValueType> make_map_item(KeyType&& key, ValueType&& value) {
  template <class KeyType, class ValueType> inline
  MapItem<KeyType, ValueType> make_map_item(KeyType && key, ValueType && value)
  {
    return {std::forward<KeyType>(key), std::forward<ValueType>(value)};
  }

    namespace detail {
  namespace detail
  {
    //! Tag for Version, which due to its anonymous namespace, becomes a different
    //! type in each translation unit
    /*! This allows CEREAL_CLASS_VERSION to be safely called in a header file */
        namespace {
            struct version_binding_tag {};
        } // namespace
    namespace{ struct version_binding_tag {}; }

    // ######################################################################
    //! Version information class
    /*! This is the base case for classes that have not been explicitly
        registered */
        template <class T, class BindingTag = version_binding_tag> struct Version {
    template <class T, class BindingTag = version_binding_tag> struct Version
    {
      static const std::uint32_t version = 0;
      // we don't need to explicitly register these types since they
      // always get a version number of 0
    };

    //! Holds all registered version information
        struct Versions {
    struct Versions
    {
      std::unordered_map<std::size_t, std::uint32_t> mapping;

            std::uint32_t find(std::size_t hash, std::uint32_t version) {
      std::uint32_t find( std::size_t hash, std::uint32_t version )
      {
        const auto result = mapping.emplace( hash, version );
        return result.first->second;
      }
+752 −667

File changed.

Preview size limit exceeded, changes collapsed.

Loading