Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Dft_Pair_Cmp< Key, Data, Cmp > Struct Template Reference

Default comparator for pair types in hash maps. More...

#include <ahDry.H>

Inheritance diagram for Aleph::Dft_Pair_Cmp< Key, Data, Cmp >:
[legend]

Public Member Functions

 Dft_Pair_Cmp () noexcept(std::is_nothrow_default_constructible_v< Cmp >)
 Builds the comparator of the keys by default.
 
 Dft_Pair_Cmp (Cmp __cmp) noexcept(std::is_nothrow_constructible_v< Cmp, Cmp & >)
 Wraps the comparator __cmp of the keys.
 
bool operator() (const std::pair< Key, Data > &p1, const std::pair< Key, Data > &p2) const noexcept(std::is_nothrow_invocable_r_v< bool, const Cmp &, const Key &, const Key & >)
 Pair vs Pair comparison; it throws what cmp throws.
 
bool operator() (const std::pair< Key, Data > &p, const Key &k) const noexcept(std::is_nothrow_invocable_r_v< bool, const Cmp &, const Key &, const Key & >)
 Heterogeneous: Pair vs Key; it throws what cmp throws.
 
bool operator() (const Key &k, const std::pair< Key, Data > &p) const noexcept(std::is_nothrow_invocable_r_v< bool, const Cmp &, const Key &, const Key & >)
 Heterogeneous: Key vs Pair; it throws what cmp throws.
 

Public Attributes

Cmp cmp
 

Detailed Description

template<typename Key, typename Data, class Cmp = std::equal_to<Key>>
struct Aleph::Dft_Pair_Cmp< Key, Data, Cmp >

Default comparator for pair types in hash maps.

Wraps a key comparator to work with std::pair<Key, Data>. Supports heterogeneous comparison (Pair vs Key).

Its comparisons are noexcept only if those of Cmp are, with the conversion of their result to bool, so that a map whose comparison throws lets the exception reach its caller.

Template Parameters
KeyKey type
DataData type
CmpKey comparator (default: std::equal_to<Key>)

Definition at line 205 of file ahDry.H.

Constructor & Destructor Documentation

◆ Dft_Pair_Cmp() [1/2]

template<typename Key , typename Data , class Cmp = std::equal_to<Key>>
Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::Dft_Pair_Cmp ( )
inlinenoexcept

Builds the comparator of the keys by default.

It is a constructor apart from the one that takes the comparator, and not a default argument of that one: GCC and Clang do not count a default argument in the noexcept of the implicit default constructor of a class that holds or inherits this one, and what that argument threw would end the program there.

Exceptions
Whatthe default construction of Cmp throws; nothing when it is noexcept, so that a map whose comparator has no state is built without throwing, and its tree too.

Definition at line 221 of file ahDry.H.

◆ Dft_Pair_Cmp() [2/2]

template<typename Key , typename Data , class Cmp = std::equal_to<Key>>
Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::Dft_Pair_Cmp ( Cmp  __cmp)
inlinenoexcept

Wraps the comparator __cmp of the keys.

Parameters
[in]__cmpThe comparator, which is copied.
Exceptions
Whatthe copy of __cmp throws: a copy from a Cmp that is not const, which a comparator may have apart from the one from a const one.

Definition at line 231 of file ahDry.H.

Member Function Documentation

◆ operator()() [1/3]

template<typename Key , typename Data , class Cmp = std::equal_to<Key>>
bool Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::operator() ( const Key &  k,
const std::pair< Key, Data > &  p 
) const
inlinenoexcept

Heterogeneous: Key vs Pair; it throws what cmp throws.

Definition at line 253 of file ahDry.H.

References Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::cmp, and k.

◆ operator()() [2/3]

template<typename Key , typename Data , class Cmp = std::equal_to<Key>>
bool Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::operator() ( const std::pair< Key, Data > &  p,
const Key &  k 
) const
inlinenoexcept

Heterogeneous: Pair vs Key; it throws what cmp throws.

Definition at line 244 of file ahDry.H.

References Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::cmp, and k.

◆ operator()() [3/3]

template<typename Key , typename Data , class Cmp = std::equal_to<Key>>
bool Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::operator() ( const std::pair< Key, Data > &  p1,
const std::pair< Key, Data > &  p2 
) const
inlinenoexcept

Pair vs Pair comparison; it throws what cmp throws.

Definition at line 235 of file ahDry.H.

References Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::cmp.

Member Data Documentation

◆ cmp

template<typename Key , typename Data , class Cmp = std::equal_to<Key>>
Cmp Aleph::Dft_Pair_Cmp< Key, Data, Cmp >::cmp

The documentation for this struct was generated from the following file: