1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef CHECK_CONSECUTIVE_H
10 #define CHECK_CONSECUTIVE_H
12 // <unordered_multiset>
13 // <unordered_multimap>
19 // Check consecutive equal values in an unordered_multiset iterator
20 template <typename Iter
>
21 void CheckConsecutiveValues(Iter pos
, Iter end
, typename
Iter::value_type value
, std::size_t count
)
23 for ( std::size_t i
= 0; i
< count
; ++i
)
26 assert(*pos
== value
);
29 assert(pos
== end
|| *pos
!= value
);
32 // Check consecutive equal keys in an unordered_multimap iterator
33 template <typename Iter
>
34 void CheckConsecutiveKeys(Iter pos
, Iter end
, typename
Iter::value_type::first_type key
, std::multiset
<typename
Iter::value_type::second_type
>& values
)
36 while (!values
.empty())
39 assert(pos
->first
== key
);
40 assert(values
.find(pos
->second
) != values
.end());
41 values
.erase(values
.find(pos
->second
));
44 assert(pos
== end
|| pos
->first
!= key
);