P4C
The P4 Compiler
Loading...
Searching...
No Matches
assoc::map< Key, T, Compare, Allocator, Itble > Class Template Reference

#include <assoc.h>

Inheritance diagram for assoc::map< Key, T, Compare, Allocator, Itble >:
[legend]

Public Types

using mapped_type = typename Base::mapped_type
 

Public Member Functions

 map (std::initializer_list< typename Base::value_type > init, const Compare &comp=Compare(), const Allocator &alloc=Allocator())
 
void swap (map &other)
 
const std::map< Key, T, Compare, Allocator > & unstable_iterable () const
 

Detailed Description

template<typename Key, typename T, typename Compare = std::less<Key>, typename Allocator = std::allocator<std::pair<const Key, T>>, Iterable Itble = Iterable::Auto>
class assoc::map< Key, T, Compare, Allocator, Itble >

Works just like a normal std::map, except it cannot be iterated over if the key is not stable (unless explicitly overridden by the last template parameter or preferably use of iterable_map or non_iterable_map).

See also
namespace assoc

Member Function Documentation

◆ unstable_iterable()

template<typename Key , typename T , typename Compare = std::less<Key>, typename Allocator = std::allocator<std::pair<const Key, T>>, Iterable Itble = Iterable::Auto>
const std::map< Key, T, Compare, Allocator > & assoc::map< Key, T, Compare, Allocator, Itble >::unstable_iterable ( ) const
inline

Extract an iterable that can be iterated over even if this container is not iterable. This is intended for targeted use at places where it is actually safe to iterate over a container with unspecified order – i.e. in cases where the result does in no way depend on the iteration order. An example can be checking if a given value is present in the map.