Skip to content

Commit c9a2c37

Browse files
authored
[oneTBB] Changing description for containers deduction guides (#355)
* Add deduction guides rework * Apply multiple comments from the PR * Minor rephrase * Adding default arguments for Allocator for unordered_map * Update copyright year
1 parent cbba7ba commit c9a2c37

File tree

15 files changed

+466
-299
lines changed

15 files changed

+466
-299
lines changed

source/elements/oneTBB/source/containers/concurrent_bounded_queue_cls/deduction_guides.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
55
================
66
Deduction guides
77
================
88

9-
Where possible, constructors of ``tbb::concurrent_bounded_queue`` support class template argument
10-
deduction (since C++17):
9+
If possible, ``concurrent_bounded_queue`` constructors support class template argument deduction (since C++17).
10+
Copy and move constructors, including constructors with an explicit ``allocator_type`` argument,
11+
provide implicitly-generated deduction guides.
12+
In addition, the following explicit deduction guide is provided:
1113

1214
.. code:: cpp
1315
1416
template <typename InputIterator,
15-
typename Allocator = cache_aligned_allocator<iterator_value_t<InputIterator>>
16-
concurrent_bounded_queue( InputIterator, InputIterator, const Allocator& = Allocator() )
17-
-> concurrent_bounded_queue<iterator_value_t<InputIterator>, Allocator>;
17+
typename Allocator = tbb::cache_aligned_allocator<iterator_value_t<InputIterator>>
18+
concurrent_bounded_queue( InputIterator, InputIterator,
19+
Allocator = Allocator() )
20+
-> concurrent_bounded_queue<iterator_value_t<InputIterator>,
21+
Allocator>;
1822
1923
Where the type alias ``iterator_value_t`` is defined as follows:
2024

@@ -23,6 +27,11 @@ Where the type alias ``iterator_value_t`` is defined as follows:
2327
template <typename InputIterator>
2428
using iterator_value_t = typename std::iterator_traits<InputIterator>::value_type;
2529
30+
This deduction guides only participate in the overload resolution if the following requirements are met:
31+
32+
* The ``InputIterator`` type meets the ``InputIterator`` requirements described in the [input.iterators] section of the ISO C++ Standard.
33+
* The ``Allocator`` type meets the ``Allocator`` requirements described in the [allocator.requirements] section of the ISO C++ Standard.
34+
2635
**Example**
2736

2837
.. code:: cpp

source/elements/oneTBB/source/containers/concurrent_hash_map_cls.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
@@ -33,6 +33,7 @@ Class Template Synopsis
3333
using pointer = typename std::allocator_traits<Allocator>::pointer;
3434
using const_pointer = typename std::allocator_traits<Allocator>::const_pointer;
3535
36+
using hash_compare_type = HashCompare;
3637
using allocator_type = Allocator;
3738
3839
using size_type = <implementation-defined unsigned integer type>;
@@ -50,31 +51,31 @@ Class Template Synopsis
5051
// Construction, destruction, copying
5152
concurrent_hash_map();
5253
53-
explicit concurrent_hash_map( const HashCompare& compare,
54+
explicit concurrent_hash_map( const hash_compare_type& compare,
5455
const allocator_type& alloc = allocator_type() );
5556
5657
explicit concurrent_hash_map( const allocator_type& alloc );
5758
58-
concurrent_hash_map( size_type n, const HashCompare& compare,
59+
concurrent_hash_map( size_type n, const hash_compare_type& compare,
5960
const allocator_type& alloc = allocator_type() );
6061
6162
concurrent_hash_map( size_type n, const allocator_type& alloc = allocator_type() );
6263
6364
template <typename InputIterator>
6465
concurrent_hash_map( InputIterator first, InputIterator last,
65-
const HashCompare& compare,
66+
const hash_compare_type& compare,
6667
const allocator_type& alloc = allocator_type() );
6768
6869
template <typename InputIterator>
6970
concurrent_hash_map( InputIterator first, InputIterator last,
7071
const allocator_type& alloc = allocator_type() );
7172
7273
concurrent_hash_map( std::initializer_list<value_type> init,
73-
const HashCompare& compare,
74+
const hash_compare_type& compare = hash_compare_type(),
7475
const allocator_type& alloc = allocator_type() );
7576
7677
concurrent_hash_map( std::initializer_list<value_type> init,
77-
const allocator_type& alloc = allocator_type() );
78+
const allocator_type& alloc );
7879
7980
concurrent_hash_map( const concurrent_hash_map& other );
8081
concurrent_hash_map( const concurrent_hash_map& other,

source/elements/oneTBB/source/containers/concurrent_hash_map_cls/construct_destroy_copy.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
@@ -13,7 +13,7 @@ Empty container constructors
1313
1414
concurrent_hash_map();
1515
16-
explicit concurrent_hash_map( const HashCompare& compare,
16+
explicit concurrent_hash_map( const hash_compare_type& compare,
1717
const allocator_type& alloc = allocator_type() );
1818
1919
explicit concurrent_hash_map( const allocator_type& alloc );
@@ -28,7 +28,7 @@ Empty container constructors
2828

2929
.. code:: cpp
3030
31-
concurrent_hash_map( size_type n, const HashCompare& compare,
31+
concurrent_hash_map( size_type n, const hash_compare_type& compare,
3232
const allocator_type& alloc = allocator_type() );
3333
3434
concurrent_hash_map( size_type n, const allocator_type& alloc = allocator_type() );
@@ -45,7 +45,7 @@ Constructors from the sequence of elements
4545
4646
template <typename InputIterator>
4747
concurrent_hash_map( InputIterator first, InputIterator last,
48-
const HashCompare& compare,
48+
const hash_compare_type& compare,
4949
const allocator_type& alloc = allocator_type() );
5050
5151
template <typename InputIterator>
@@ -70,7 +70,7 @@ Constructors from the sequence of elements
7070
.. code:: cpp
7171
7272
concurrent_hash_map( std::initializer_list<value_type> init,
73-
const HashCompare& compare,
73+
const hash_compare_type& compare = hash_compare_type(),
7474
const allocator_type& alloc = allocator_type() );
7575
7676
Equivalent to ``concurrent_hash_map(init.begin(), init.end(), compare, alloc)``.
@@ -80,7 +80,7 @@ Constructors from the sequence of elements
8080
.. code:: cpp
8181
8282
concurrent_hash_map( std::initializer_list<value_type> init,
83-
const allocator_type& alloc = allocator_type() );
83+
const allocator_type& alloc );
8484
8585
Equivalent to ``concurrent_hash_map(init.begin(), init.end(), alloc)``.
8686

source/elements/oneTBB/source/containers/concurrent_hash_map_cls/deduction_guides.rst

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,55 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
55
================
66
Deduction guides
77
================
88

9-
Where possible, constructors of ``concurrent_hash_map`` support
10-
class template argument deduction (since C++17):
9+
If possible, ``concurrent_hash_map`` constructors support class template argument deduction (since C++17).
10+
Copy and move constructors, including constructors with an explicit ``allocator_type`` argument,
11+
provide implicitly-generated deduction guides.
12+
In addition, the following explicit deduction guides are provided:
1113

1214
.. code:: cpp
1315
1416
template <typename InputIterator,
15-
typename HashCompare,
17+
typename HashCompare = tbb_hash_compare<iterator_key_t<InputIterator>>,
1618
typename Allocator = tbb_allocator<iterator_alloc_value_t<InputIterator>>>
1719
concurrent_hash_map( InputIterator, InputIterator,
18-
const HashCompare&,
19-
const Allocator& = Allocator() )
20+
HashCompare = HashCompare(),
21+
Allocator = Allocator() )
2022
-> concurrent_hash_map<iterator_key_t<InputIterator>,
2123
iterator_mapped_t<InputIterator>,
2224
HashCompare,
2325
Allocator>;
2426
2527
template <typename InputIterator,
26-
typename Allocator = tbb_allocator<iterator_alloc_value_t<InputIterator>>>
27-
concurrent_hash_map( InputIterator, InputIterator,
28-
const Allocator& = Allocator() )
28+
typename Allocator>
29+
concurrent_hash_map( InputIterator, InputIterator, Allocator )
2930
-> concurrent_hash_map<iterator_key_t<InputIterator>,
3031
iterator_mapped_t<InputIterator>,
3132
tbb_hash_compare<iterator_key_t<InputIterator>>,
3233
Allocator>;
3334
34-
template <typename Key,
35-
typename T,
36-
typename HashCompare,
35+
template <typename Key, typename T,
36+
typename HashCompare = tbb_hash_compare<std::remove_const_t<Key>>,
3737
typename Allocator = tbb_allocator<std::pair<const Key, T>>>
38-
concurrent_hash_map( std::initializer_list<std::pair<const Key, T>>,
39-
const HashCompare&,
40-
const Allocator& = Allocator() )
41-
-> concurrent_hash_map<Key,
38+
concurrent_hash_map( std::initializer_list<std::pair<Key, T>>,
39+
HashCompare = HashCompare(),
40+
Allocator = Allocator() )
41+
-> concurrent_hash_map<std::remove_const_t<Key>,
4242
T,
4343
HashCompare,
4444
Allocator>;
4545
46-
template <typename Key,
47-
typename T,
48-
typename Allocator = tbb_allocator<std::pair<const Key, T>>>
49-
concurrent_hash_map( std::initializer_list<std::pair<const Key, T>>,
50-
const Allocator& = Allocator() )
51-
-> concurrent_hash_map<Key,
46+
template <typename Key, typename T,
47+
typename Allocator>
48+
concurrent_hash_map( std::initializer_list<std::pair<Key, T>>,
49+
Allocator )
50+
-> concurrent_hash_map<std::remove_const_t<Key>,
5251
T,
53-
tbb_hash_compare<Key>,
52+
tbb_hash_compare<std::remove_const_t<Key>>,
5453
Allocator>;
5554
5655
Where the type aliases ``iterator_key_t``, ``iterator_mapped_t``, and ``iterator_alloc_value_t``
@@ -68,6 +67,12 @@ are defined as follows:
6867
using iterator_alloc_value_t = std::pair<std::add_const_t<iterator_key_t<InputIterator>,
6968
iterator_mapped_t<InputIterator>>>;
7069
70+
These deduction guides only participate in the overload resolution if the following requirements are met:
71+
72+
* The ``InputIterator`` type meets the ``InputIterator`` requirements described in the [input.iterators] section of the ISO C++ Standard.
73+
* The ``Allocator`` type meets the ``Allocator`` requirements described in the [allocator.requirements] section of the ISO C++ Standard.
74+
* The ``HashCompare`` type does not meet the ``Allocator`` requirements.
75+
7176
**Example**
7277

7378
.. code:: cpp

source/elements/oneTBB/source/containers/concurrent_map_cls/deduction_guides.rst

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
1+
.. SPDX-FileCopyrightText: 2019-2021 Intel Corporation
22
..
33
.. SPDX-License-Identifier: CC-BY-4.0
44
55
================
66
Deduction guides
77
================
88

9-
Where possible, constructors of ``concurrent_map`` support class template argument
10-
deduction (since C++17):
9+
If possible, ``concurrent_map`` constructors support class template argument deduction (since C++17).
10+
Copy and move constructors, including constructors with an explicit ``allocator_type`` argument,
11+
provide implicitly-generated deduction guides.
12+
In addition, the following explicit deduction guides are provided:
1113

1214
.. code:: cpp
1315
1416
template <typename InputIterator,
1517
typename Compare = std::less<iterator_key_t<InputIterator>>,
1618
typename Allocator = tbb_allocator<iterator_alloc_value_t<InputIterator>>>
17-
concurrent_map( InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator() )
19+
concurrent_map( InputIterator, InputIterator,
20+
Compare = Compare(),
21+
Allocator = Allocator() )
1822
-> concurrent_map<iterator_key_t<InputIterator>,
1923
iterator_mapped_t<InputIterator>,
2024
Compare,
2125
Allocator>;
2226
2327
template <typename InputIterator,
2428
typename Allocator>
25-
concurrent_map( InputIterator, InputIterator, Allocator )
29+
concurrent_map( InputIterator, InputIterator,
30+
Allocator )
2631
-> concurrent_map<iterator_key_t<InputIterator>,
2732
iterator_mapped_t<InputIterator>,
2833
std::less<iterator_key_t<InputIterator>>,
2934
Allocator>;
3035
31-
template <typename Key,
32-
typename T,
33-
typename Compare = std::less<Key>,
36+
template <typename Key, typename T,
37+
typename Compare = std::less<std::remove_const_t<Key>>,
3438
typename Allocator = tbb_allocator<std::pair<const Key, T>>>
35-
concurrent_map( std::initializer_list<std::pair<Key, T>>, Compare = Compare(), Allocator = Allocator() )
36-
-> concurrent_map<Key, T, Compare, Allocator>;
39+
concurrent_map( std::initializer_list<std::pair<Key, T>>,
40+
Compare = Compare(),
41+
Allocator = Allocator() )
42+
-> concurrent_map<std::remove_const_t<Key>,
43+
T,
44+
Compare,
45+
Allocator>;
3746
38-
template <typename Key,
39-
typename T,
47+
template <typename Key, typename T,
4048
typename Allocator>
4149
concurrent_map( std::initializer_list<std::pair<Key, T>>, Allocator )
42-
-> concurrent_map<Key, T, std::less<Key>, Allocator>;
50+
-> concurrent_map<std::remove_const_t<Key>,
51+
T,
52+
std::less<std::remove_const_t<Key>>,
53+
Allocator>;
4354
4455
where the type aliases ``iterator_key_t``, ``iterator_mapped_t``, ``iterator_alloc_value_t`` are defined as follows:
4556

@@ -55,6 +66,12 @@ where the type aliases ``iterator_key_t``, ``iterator_mapped_t``, ``iterator_all
5566
using iterator_alloc_value_t = std::pair<std::add_const_t<iterator_key_t<InputIterator>>,
5667
iterator_mapped_t<InputIterator>>;
5768
69+
These deduction guides only participate in the overload resolution if the following requirements are met:
70+
71+
* The ``InputIterator`` type meets the ``InputIterator`` requirements described in the [input.iterators] section of the ISO C++ Standard.
72+
* The ``Allocator`` type meets the ``Allocator`` requirements described in the [allocator.requirements] section of the ISO C++ Standard.
73+
* The ``Compare`` type does not meet the ``Allocator`` requirements.
74+
5875
**Example**
5976

6077
.. code:: cpp

0 commit comments

Comments
 (0)