map.h

This section contains reference documentation for working with protocol buffer classes in C++.

#include <google/protobuf/map.h>
namespace google::protobuf

This file defines the map container and its helpers to support protobuf maps.

The Map and MapIterator types are provided by this header file. Please avoid using other types defined here, unless they are public types within Map or MapIterator, such as Map::value_type.

Classes in this file

This is the class for Map's internal value_type.
Map is an associative container type used to store protobuf map fields.
Iterators.

template alias MapPair

#include <google/protobuf/map.h>
namespace google::protobuf

template <typename , typename >

This is the class for Map's internal value_type, which is just an alias to std::pair.

template class Map

#include <google/protobuf/map.h>
namespace google::protobuf

template <typename , typename >

Map is an associative container type used to store protobuf map fields.

Each Map instance may or may not use a different hash function, a different iteration order, and so on. E.g., please don't examine implementation details to decide if the following would work: Map<int, int> m0, m1; m0[[]0] = m1[[]0] = m0[[]1] = m1[[]1] = 0; assert(m0.begin()->first == m1.begin()->first); // Bug!

Map's interface is similar to std::unordered_map, except that Map is not designed to play well with exceptions.

Members

typedef
Key key_type
typedef
T mapped_type
typedef
MapPair< Key, T > value_type
typedef
value_type * pointer
typedef
const value_type * const_pointer
typedef
value_type & reference
typedef
const value_type & const_reference
typedef
size_t size_type
typedef
typename internal::TransparentSupport< Key >::hash hasher
constexpr
Map()
explicit
Map(Arena * arena)
Map(const Map & other)
Map(Map && other)
Map &
operator=(Map && other)
template
Map(const InputIt & first, const InputIt & last)
~Map()
iterator
begin()
iterator
end()
const_iterator
begin() const
const_iterator
end() const
const_iterator
cbegin() const
const_iterator
cend() const
size_type
size() const
Capacity.
bool
empty() const
template T &
operator[](const key_arg< K > & key)
Element access.
template T &
operator[](key_arg< K > && key)
template const T &
at(const key_arg< K > & key) const
template T &
at(const key_arg< K > & key)
template size_type
count(const key_arg< K > & key) const
Lookup.
template const_iterator
find(const key_arg< K > & key) const
template iterator
find(const key_arg< K > & key)
template bool
contains(const key_arg< K > & key) const
template std::pair< const_iterator, const_iterator >
equal_range(const key_arg< K > & key) const
template std::pair< iterator, iterator >
equal_range(const key_arg< K > & key)
std::pair< iterator, bool >
insert(const value_type & value)
insert
template void
insert(InputIt first, InputIt last)
void
insert(std::initializer_list< value_type > values)
template size_type
erase(const key_arg< K > & key)
Erase and clear.
iterator
erase(iterator pos)
void
erase(iterator first, iterator last)
void
clear()
Map &
operator=(const Map & other)
Assign.
void
swap(Map & other)
void
InternalSwap(Map & other)
hasher
hash_function() const
Access to hasher. more...
size_t
SpaceUsedExcludingSelfLong() const

hasher Map::hash_function() const

Access to hasher.

Currently this returns a copy, but it may be modified to return a const reference in the future.

class Map::const_iterator

#include <google/protobuf/map.h>
namespace google::protobuf

Iterators.

Members

typedef
std::forward_iterator_tag iterator_category
typedef
typename Map::value_type value_type
typedef
ptrdiff_t difference_type
typedef
const value_type * pointer
typedef
const value_type & reference
const_iterator()
explicit
const_iterator(const InnerIt & it)
const_reference
operator*() const
const_pointer
operator->() const
const_iterator &
operator++()
const_iterator
operator++(int )

class Map::iterator

#include <google/protobuf/map.h>
namespace google::protobuf

Members

typedef
std::forward_iterator_tag iterator_category
typedef
typename Map::value_type value_type
typedef
ptrdiff_t difference_type
typedef
value_type * pointer
typedef
value_type & reference
iterator()
explicit
iterator(const InnerIt & it)
reference
operator*() const
pointer
operator->() const
iterator &
operator++()
iterator
operator++(int )
operator const_iterator() const
Allow implicit conversion to const_iterator.