Skip to content

Commit 69c0ec4

Browse files
committed
review
1 parent 22d245e commit 69c0ec4

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

libcxx/include/__iterator/product_iterator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
// - template <size_t _N>
2424
// static decltype(auto) Traits::__get_iterator_element(It&& __it)
2525
// Returns the _Nth iterator element of the given product iterator.
26+
//
27+
// - template <class... _Iters>
28+
// static _Iterator __make_product_iterator(_Iters&&...);
29+
// Creates a product iterator from the given underlying iterators.
2630

2731
#include <__config>
2832
#include <__cstddef/size_t.h>

libcxx/test/benchmarks/containers/associative/flat_map.bench.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <flat_map>
1212
#include <utility>
13-
#include <ranges>
1413

1514
#include "associative_container_benchmarks.h"
1615
#include "../../GenerateInput.h"

libcxx/test/libcxx/iterators/product_iterator.pass.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17
1010

11+
#include <flat_map>
1112
#include <ranges>
1213
#include <type_traits>
14+
#include <utility>
1315

1416
#include "test_macros.h"
1517
#include "test_iterators.h"
@@ -34,6 +36,21 @@ constexpr bool test() {
3436

3537
assert(*it1 == 1);
3638
}
39+
if (!std::is_constant_evaluated()) {
40+
// Test __make_product_iterator
41+
using M = std::flat_map<int, int>;
42+
M m{{1, 1}, {2, 2}, {3, 3}};
43+
using Iter = std::ranges::iterator_t<const M>;
44+
const auto& keys = m.keys();
45+
const auto& values = m.values();
46+
47+
auto it_keys = std::ranges::begin(keys);
48+
auto it_values = std::ranges::begin(values);
49+
50+
auto it = std::__product_iterator_traits<Iter>::__make_product_iterator(it_keys, it_values);
51+
assert(it->first == 1);
52+
assert(it->second == 1);
53+
}
3754

3855
return true;
3956
}

0 commit comments

Comments
 (0)