chromium/mojo/public/cpp/bindings/array_traits_stl.h

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_
#define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_

#include <array>
#include <map>
#include <set>
#include <type_traits>
#include <unordered_set>

#include "base/containers/flat_set.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "mojo/public/cpp/bindings/array_traits.h"
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"

namespace mojo {

ArrayTraits<std::unordered_set<T>>;

// This ArrayTraits specialization is used only for serialization.
ArrayTraits<std::set<T>>;

// This ArrayTraits specialization is used only for serialization.
ArrayTraits<base::flat_set<T>>;

template <typename K, typename V>
struct MapValuesArrayView {};

// Convenience function to create a MapValuesArrayView<> that infers the
// template arguments from its argument type.
template <typename K, typename V>
MapValuesArrayView<K, V> MapValuesToArray(const std::map<K, V>& map) {}

// This ArrayTraits specialization is used only for serialization and converts
// a map<K, V> into an array<V>, discarding the keys.
ArrayTraits<MapValuesArrayView<K, V>>;

// This ArrayTraits specialization is used for conversion between
// std::array<T, N> and array<T, N>.
ArrayTraits<std::array<T, N>>;

}  // namespace mojo

#endif  // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_