Sha256: a49768f92b785c6bb0bcdbbdde5dfcfc53d2f316775b727c32cb32a3d7359f50

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 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_ARRAY_TRAITS_HPP
#define TAO_JSON_CONTRIB_ARRAY_TRAITS_HPP

#include <array>

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

#include "internal/array_traits.hpp"

namespace tao::json
{
   template< typename T, std::size_t N >
   struct array_traits
      : internal::array_traits< std::array< T, N > >
   {
      template< template< typename... > class Traits, typename... With >
      static void to( const basic_value< Traits >& v, std::array< T, N >& r, With&... with )
      {
         const auto& a = v.get_array();
         for( std::size_t i = 0; i < N; ++i ) {
            a[ i ].to_with( r[ i ], with... );
         }
      }

      template< template< typename... > class Traits, typename Producer >
      static void consume( Producer& parser, std::array< T, N >& r )
      {
         auto s = parser.begin_array();
         for( std::size_t i = 0; i < N; ++i ) {
            parser.element( s );
            json::consume< Traits >( parser, r[ i ] );
         }
         parser.end_array( s );
      }
   };

}  // 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/array_traits.hpp
couchbase-3.4.4 ext/couchbase/third_party/json/include/tao/json/contrib/array_traits.hpp
couchbase-3.4.3 ext/couchbase/third_party/json/include/tao/json/contrib/array_traits.hpp
couchbase-3.4.2 ext/couchbase/third_party/json/include/tao/json/contrib/array_traits.hpp
couchbase-3.4.1 ext/couchbase/third_party/json/include/tao/json/contrib/array_traits.hpp
couchbase-3.4.0 ext/couchbase/third_party/json/include/tao/json/contrib/array_traits.hpp
couchbase-3.3.0 ext/couchbase/third_party/json/include/tao/json/contrib/array_traits.hpp