Template Struct ConstexprMap#
Defined in File ConstexprMap.h
Struct Documentation#
-
template<typename Key, typename Value, usize Size, typename KeyEqual = std::equal_to<Key>>
struct ConstexprMap# Compile-time and thread safe, fixed size map implementation.
- Template Parameters:
Key – Key type for the map.
Value – Value type for the map.
Size – Size for the map.
Public Types
-
using reference = value_type&#
-
using const_reference = const value_type&#
-
using pointer = value_type*#
-
using const_pointer = const value_type*#
-
using iterator = value_type*#
-
using const_iterator = const value_type*#
Public Functions
-
constexpr ConstexprMap() = default#
-
inline constexpr ConstexprMap(const ConstexprMap &other)#
-
inline constexpr ConstexprMap(ConstexprMap &&other) noexcept#
-
inline explicit constexpr ConstexprMap(std::array<value_type, Size> data)#
-
~ConstexprMap() = default#
Destructs the ConstexprMap. The destructor of the elements are calaled and the used storage is deallocated.
Note
If the elements are pointers, the pointer-to objects are not destroyed.
-
inline constexpr ConstexprMap &operator=(const ConstexprMap &other)#
Replaces the contents of the container. Copy assignment operator. Replaces the contents with a copy of the contents of other.
- Parameters:
other – Another container to use as data source.
- Returns:
*this.
-
inline constexpr ConstexprMap &operator=(ConstexprMap &&other) noexcept#
Replaces the contents of the container. Move assignment operator. Replaces the contents with those of other using move semantics (i.e. the data in other is moved from other into this container). other is in a valid but unspecified state afterwards.
- Parameters:
other – Another container to use as data source.
- Returns:
*this.
-
inline constexpr ConstexprMap &operator=(const std::initializer_list<value_type> iList)#
Replaces the contents of the container. Replaces the contents with those identified by intializer list iList.
- Parameters:
iList – Initializer list to use as data source.
- Returns:
*this.
-
inline constexpr iterator begin() noexcept#
Returns an iterator to the first element of the ConstexprMap.
Note
If the ConstexprMap is empty, the returned iterator will be equal to end().
- Returns:
Iterator to the first element.
-
inline constexpr const_iterator begin() const noexcept#
Returns an iterator to the first element of the ConstexprMap.
Note
If the ConstexprMap is empty, the returned iterator will be equal to end().
- Returns:
Iterator to the first element.
-
inline constexpr const_iterator cbegin() const noexcept#
Returns an iterator to the first element of the ConstexprMap.
Note
If the ConstexprMap is empty, the returned iterator will be equal to end().
- Returns:
Iterator to the first element.
-
inline constexpr iterator end() noexcept#
Returns an iterator to the element following the last element of the ConstexprMap.
Note
This element acts as a placeholder; attempting to access it results in undefined behavior.
- Returns:
Iterator to the element following the last element.
-
inline constexpr const_iterator end() const noexcept#
Returns an iterator to the element following the last element of the ConstexprMap.
Note
This element acts as a placeholder; attempting to access it results in undefined behavior.
- Returns:
Iterator to the element following the last element.
-
inline constexpr const_iterator cend() const noexcept#
Returns an iterator to the element following the last element of the ConstexprMap.
Note
This element acts as a placeholder; attempting to access it results in undefined behavior.
- Returns:
Iterator to the element following the last element.
-
inline constexpr std::optional<mapped_type> at(const key_type &key) const#
Retrieve the mapped value of the element with key equivalent to key. If no such element exists, an empty optional is returned.
- Parameters:
key – Key of the element to find.
- Returns:
Mapped value of the requested element or empty optional if not found.
-
template<typename K>
inline constexpr std::optional<mapped_type> at(const K &key) const# Retrieve the mapped value of the element with key equivalent to key. If no such element exists, an empty optional is returned.
- Parameters:
key – Key of the element to find.
- Returns:
Mapped value of the requested element or empty optional if not found.
-
inline constexpr iterator find(const Key &key)#
Finds an element with key equivalent to key.
- Parameters:
key – Key value of the element to search for.
- Returns:
An iterator to the requested element. If no such element is found, past-the-end (see end()) iterator is returned.
-
inline constexpr const_iterator find(const Key &key) const#
Finds an element with key equivalent to key.
- Parameters:
key – Key value of the element to search for.
- Returns:
An iterator to the requested element. If no such element is found, past-the-end (see end()) iterator is returned.
-
template<typename K>
inline constexpr iterator find(const K &x)# Finds an element with key equivalent to key.
- Parameters:
key – Key value of the element to search for.
- Returns:
An iterator to the requested element. If no such element is found, past-the-end (see end()) iterator is returned.
-
template<typename K>
inline constexpr const_iterator find(const K &x) const# Finds an element with key equivalent to key.
- Parameters:
key – Key value of the element to search for.
- Returns:
An iterator to the requested element. If no such element is found, past-the-end (see end()) iterator is returned.
-
inline constexpr bool contains(const key_type &key) const#
Check if there is an element with key equivalent to key in the container.
- Parameters:
key – Key value of the element to search for.
- Returns:
True if there is such an element, false otherwise.
-
inline constexpr bool empty() const noexcept#
Checks if the container has no elements.
- Returns:
True if the container is empty, false otherwise.
-
inline constexpr size_type size() const noexcept#
Returns the number of elements in the container.
- Returns:
Number of elements in the container.
-
inline constexpr mapped_type operator[](const key_type &key) const#
Retrieve the value that is mapped to a key equivalent to key.
Warning
This function throws an exception if no element was found.
- Parameters:
key – Key of the element to find.
- Returns:
Mapped value of the requested element.
-
template<typename K>
inline constexpr mapped_type operator[](K &&x) const# Retrieve the value that is mapped to a key equivalent to key.
Warning
This function throws an exception if no element was found.
- Parameters:
key – Key of the element to find.
- Returns:
Mapped value of the requested element.
-
inline constexpr size_type count(const key_type &key) const#
Retrieve the number of elements with key that compares equal to the specified argument key, which is either 1 or 0 since this container does not allow duplicates.
- Parameters:
key – Key value of the elements to count.
- Returns:
Number of elements with key key, that is either 1 or 0.