19bfdb770SEric Fiselier //===----------------------------------------------------------------------===//
29bfdb770SEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
69bfdb770SEric Fiselier //
79bfdb770SEric Fiselier //===----------------------------------------------------------------------===//
89bfdb770SEric Fiselier 
9*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11
109bfdb770SEric Fiselier 
119bfdb770SEric Fiselier // <map>
129bfdb770SEric Fiselier 
139bfdb770SEric Fiselier // class map
149bfdb770SEric Fiselier 
159bfdb770SEric Fiselier // template<typename K>
169bfdb770SEric Fiselier //   size_type count(const K& x) const;        // C++14
179bfdb770SEric Fiselier 
189bfdb770SEric Fiselier #include <cassert>
199bfdb770SEric Fiselier #include <map>
209bfdb770SEric Fiselier #include <utility>
219bfdb770SEric Fiselier 
229bfdb770SEric Fiselier struct Comp {
239bfdb770SEric Fiselier   using is_transparent = void;
249bfdb770SEric Fiselier 
operator ()Comp259bfdb770SEric Fiselier   bool operator()(const std::pair<int, int> &lhs,
269bfdb770SEric Fiselier                   const std::pair<int, int> &rhs) const {
279bfdb770SEric Fiselier     return lhs < rhs;
289bfdb770SEric Fiselier   }
299bfdb770SEric Fiselier 
operator ()Comp309bfdb770SEric Fiselier   bool operator()(const std::pair<int, int> &lhs, int rhs) const {
319bfdb770SEric Fiselier     return lhs.first < rhs;
329bfdb770SEric Fiselier   }
339bfdb770SEric Fiselier 
operator ()Comp349bfdb770SEric Fiselier   bool operator()(int lhs, const std::pair<int, int> &rhs) const {
359bfdb770SEric Fiselier     return lhs < rhs.first;
369bfdb770SEric Fiselier   }
379bfdb770SEric Fiselier };
389bfdb770SEric Fiselier 
main(int,char **)392df59c50SJF Bastien int main(int, char**) {
409bfdb770SEric Fiselier   std::map<std::pair<int, int>, int, Comp> s{
419bfdb770SEric Fiselier       {{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}};
429bfdb770SEric Fiselier 
439bfdb770SEric Fiselier   auto cnt = s.count(1);
449bfdb770SEric Fiselier   assert(cnt == 3);
452df59c50SJF Bastien 
462df59c50SJF Bastien   return 0;
479bfdb770SEric Fiselier }
48