Deduction guides¶
Where possible, constructors of concurrent_hash_map
support
class template argument deduction (since C++17):
template <typename InputIterator,
typename HashCompare,
typename Allocator = tbb_allocator<iterator_alloc_value_t<InputIterator>>>
concurrent_hash_map( InputIterator, InputIterator,
const HashCompare&,
const Allocator& = Allocator() )
-> concurrent_hash_map<iterator_key_t<InputIterator>,
iterator_mapped_t<InputIterator>,
HashCompare,
Allocator>;
template <typename InputIterator,
typename Allocator = tbb_allocator<iterator_alloc_value_t<InputIterator>>>
concurrent_hash_map( InputIterator, InputIterator,
const Allocator& = Allocator() )
-> concurrent_hash_map<iterator_key_t<InputIterator>,
iterator_mapped_t<InputIterator>,
tbb_hash_compare<iterator_key_t<InputIterator>>,
Allocator>;
template <typename Key,
typename T,
typename HashCompare,
typename Allocator = tbb_allocator<std::pair<const Key, T>>>
concurrent_hash_map( std::initializer_list<std::pair<const Key, T>>,
const HashCompare&,
const Allocator& = Allocator() )
-> concurrent_hash_map<Key,
T,
HashCompare,
Allocator>;
template <typename Key,
typename T,
typename Allocator = tbb_allocator<std::pair<const Key, T>>>
concurrent_hash_map( std::initializer_list<std::pair<const Key, T>>,
const Allocator& = Allocator() )
-> concurrent_hash_map<Key,
T,
tbb_hash_compare<Key>,
Allocator>;
Where the type aliases iterator_key_t
, iterator_mapped_t
, and iterator_alloc_value_t
are defined as follows:
template <typename InputIterator>
using iterator_key_t = std::remove_const_t<typename std::iterator_traits<InputIterator>::value_type::first_type>;
template <typename InputIterator>
using iterator_mapped_t = typename std::iterator_traits<InputIterator>::value_type::second_type;
template <typename InputIterator>
using iterator_alloc_value_t = std::pair<std::add_const_t<iterator_key_t<InputIterator>,
iterator_mapped_t<InputIterator>>>;
Example
#include <tbb/concurrent_hash_map.h>
#include <vector>
int main() {
std::vector<std::pair<const int, float>> v;
// Deduces chmap1 as tbb::concurrent_hash_map<int, float>
tbb::concurrent_hash_map chmap1(v.begin(), v.end());
std::allocator<std::pair<const int, float>> alloc;
// Deduces chmap2 as tbb::concurrent_hash_map<int, float,
// tbb_hash_compare<int>,
// std::allocator<std::pair<const int, float>>>
tbb::concurrent_hash_map chmap2(v.begin(), v.end(), alloc);
}