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 //===----------------------------------------------------------------------===//
13 // size_type count(const key_type& k) const;
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 #include "private_constructor.h"
21 #include "is_transparent.h"
23 #if TEST_STD_VER >= 11
25 struct FinalCompare final
{
26 bool operator()(const T
& x
, const T
& y
) const { return x
< y
; }
30 template <class Map
, class ArgType
= typename
Map::key_type
>
32 typedef typename
Map::value_type V
;
33 typedef typename
Map::size_type R
;
35 V ar
[] = {V(5, 5), V(6, 6), V(7, 7), V(8, 8), V(9, 9), V(10, 10), V(11, 11), V(12, 12)};
37 const Map
m(ar
, ar
+ sizeof(ar
) / sizeof(ar
[0]));
39 for (int i
= 0; i
< 5; ++i
) {
40 R r
= m
.count(ArgType(i
));
44 for (int i
= 5; i
< 13; ++i
) {
45 R r
= m
.count(ArgType(i
));
50 int main(int, char**) {
51 test
<std::map
<int, double> >();
52 #if TEST_STD_VER >= 11
53 typedef std::pair
<const int, double> V
;
54 test
<std::map
<int, double, std::less
<int>, min_allocator
<V
>>>();
55 test
<std::map
<int, double, FinalCompare
<int>>>();
57 #if TEST_STD_VER >= 14
58 typedef std::map
<int, double, std::less
<>> TM
;
63 typedef PrivateConstructor PC
;
64 typedef std::map
<PC
, double, std::less
<> > M
;
65 typedef M::size_type R
;
77 for (int i
= 0; i
< 5; ++i
) {
82 for (int i
= 5; i
< 13; ++i
) {
87 #endif // TEST_STD_VER >= 14