brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · fc097c1 Raw
40 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++1110 11// <map>12 13// class map14 15// template<typename K>16//   size_type count(const K& x) const;        // C++1417 18#include <cassert>19#include <map>20#include <utility>21 22struct Comp {23  using is_transparent = void;24 25  bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { return lhs < rhs; }26 27  bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }28 29  bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }30};31 32int main(int, char**) {33  std::map<std::pair<int, int>, int, Comp> s{{{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}};34 35  auto cnt = s.count(1);36  assert(cnt == 3);37 38  return 0;39}40