Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / associative / multimap / multimap.value_compare / invoke.pass.cpp
blob75a1114ed5e09319c9d6e1b1d69e4d9353bc147c
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <map>
11 // class value_compare
13 // bool operator()( const value_type& lhs, const value_type& rhs ) const;
15 #include <map>
16 #include <cassert>
17 #include <string>
18 #include <utility>
20 template <typename MMap>
21 struct CallCompMember : MMap::value_compare {
22 CallCompMember(const typename MMap::value_compare& vc) : MMap::value_compare(vc) {}
24 typedef typename MMap::value_type value_type;
25 bool operator()(const value_type& value1, const value_type& value2) const {
26 return this->comp(value1.first, value2.first);
30 int main(int, char**) {
31 typedef std::multimap<int, std::string> map_type;
33 map_type m;
34 map_type::iterator i1 = m.insert(map_type::value_type(1, "abc"));
35 map_type::iterator i2 = m.insert(map_type::value_type(2, "abc"));
37 const map_type::value_compare vc = m.value_comp();
38 CallCompMember<map_type> call_comp = m.value_comp();
40 assert(vc(*i1, *i2));
41 assert(call_comp(*i1, *i2));
43 assert(!vc(*i2, *i1));
44 assert(!call_comp(*i2, *i1));
46 return 0;