xref: /llvm-project/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp (revision 56c8ad237aa4088e61be09ca30830ee704f10018)
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 //===----------------------------------------------------------------------===//
8 
9 // <set>
10 
11 // key_compare key_comp() const;
12 // value_compare value_comp() const;
13 
14 #include <set>
15 #include <cassert>
16 
main(int,char **)17 int main(int, char**) {
18     typedef std::set<int> set_type;
19 
20     set_type s;
21     std::pair<set_type::iterator, bool> p1 = s.insert(1);
22     std::pair<set_type::iterator, bool> p2 = s.insert(2);
23 
24     const set_type& cs = s;
25 
26     assert(cs.key_comp()(*p1.first, *p2.first));
27     assert(!cs.key_comp()(*p2.first, *p1.first));
28 
29     assert(cs.value_comp()(*p1.first, *p2.first));
30     assert(!cs.value_comp()(*p2.first, *p1.first));
31 
32     return 0;
33 }
34