Sha256: 9e0cd761692a1ca4d6efb211cfef13b6631f284324cffb94901c1a8cc464d915

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

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

#ifndef TAO_JSON_CONTRIB_UNORDERED_SET_TRAITS_HPP
#define TAO_JSON_CONTRIB_UNORDERED_SET_TRAITS_HPP

#include <unordered_set>

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

#include "internal/array_traits.hpp"

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

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

}  // namespace tao::json

#endif

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
couchbase-3.2.0-universal-darwin-20 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.2.0 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.1.1 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.1.1-universal-darwin-20 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.1.0 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.0.3 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.0.3-universal-darwin-20 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.0.2 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.0.1-universal-darwin-19 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp
couchbase-3.0.1 ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp