Sha256: 20b4735ad50b873842433a439a5d400dfaeb13522fcc0014615c5e80b804374d

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/json/

#ifndef TAO_JSON_CONTRIB_LIST_TRAITS_HPP
#define TAO_JSON_CONTRIB_LIST_TRAITS_HPP

#include <list>

#include "../consume.hpp"
#include "../forward.hpp"

#include "internal/array_traits.hpp"

namespace tao::json
{
   template< typename T, typename... Ts >
   struct list_traits
      : internal::array_traits< std::list< T, Ts... > >
   {
      template< template< typename... > class Traits, typename... With >
      static void to( const basic_value< Traits >& v, std::list< T, Ts... >& r, With&... with )
      {
         const auto& a = v.get_array();
         for( const auto& i : a ) {
            r.emplace_back( i.template as_with< T >( with... ) );
         }
      }

      template< template< typename... > class Traits, typename Producer >
      static void consume( Producer& parser, std::list< T, Ts... >& r )
      {
         auto s = parser.begin_array();
         while( parser.element_or_end_array( s ) ) {
            r.emplace_back( json::consume< T, Traits >( parser ) );
         }
      }
   };

}  // namespace tao::json

#endif

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
couchbase-3.4.5 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp
couchbase-3.4.4 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp
couchbase-3.4.3 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp
couchbase-3.4.2 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp
couchbase-3.4.1 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp
couchbase-3.4.0 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp
couchbase-3.3.0 ext/couchbase/third_party/json/include/tao/json/contrib/list_traits.hpp