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 //===----------------------------------------------------------------------===//
11 // class value_compare
13 // bool operator()( const value_type& lhs, const value_type& rhs ) const;
20 template <typename Map
>
21 struct CallCompMember
: Map::value_compare
{
22 CallCompMember(const typename
Map::value_compare
& vc
) : Map::value_compare(vc
) {}
24 typedef typename
Map::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::map
<int, std::string
> map_type
;
34 std::pair
<map_type::iterator
, bool> p1
= m
.insert(map_type::value_type(1, "abc"));
35 std::pair
<map_type::iterator
, bool> p2
= 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(*p1
.first
, *p2
.first
));
41 assert(call_comp(*p1
.first
, *p2
.first
));
43 assert(!vc(*p2
.first
, *p1
.first
));
44 assert(!call_comp(*p2
.first
, *p1
.first
));