1266733Speter// -*- C++ -*-
2266733Speter
3266733Speter// Copyright (C) 2005-2022 Free Software Foundation, Inc.
4266733Speter//
5266733Speter// This file is part of the GNU ISO C++ Library.  This library is free
6266733Speter// software; you can redistribute it and/or modify it under the terms
7266733Speter// of the GNU General Public License as published by the Free Software
8266733Speter// Foundation; either version 3, or (at your option) any later
9266733Speter// version.
10266733Speter
11266733Speter// This library is distributed in the hope that it will be useful, but
12266733Speter// WITHOUT ANY WARRANTY; without even the implied warranty of
13266733Speter// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14266733Speter// General Public License for more details.
15266733Speter
16266733Speter// Under Section 7 of GPL version 3, you are granted additional
17266733Speter// permissions described in the GCC Runtime Library Exception, version
18266733Speter// 3.1, as published by the Free Software Foundation.
19266733Speter
20266733Speter// You should have received a copy of the GNU General Public License and
21266733Speter// a copy of the GCC Runtime Library Exception along with this program;
22266733Speter// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23266733Speter// <http://www.gnu.org/licenses/>.
24266733Speter
25266733Speter// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
26266733Speter
27266733Speter// Permission to use, copy, modify, sell, and distribute this software
28266733Speter// is hereby granted without fee, provided that the above copyright
29266733Speter// notice appears in all copies, and that both that copyright notice
30266733Speter// and this permission notice appear in supporting documentation. None
31266733Speter// of the above authors, nor IBM Haifa Research Laboratories, make any
32266733Speter// representation about the suitability of this software for any
33266733Speter// purpose. It is provided "as is" without express or implied
34266733Speter// warranty.
35266733Speter
36266733Speter/**
37266733Speter * @file binary_heap_/entry_cmp.hpp
38266733Speter * Contains an implementation class for a binary_heap.
39266733Speter */
40266733Speter
41266733Speter#ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
42266733Speter#define PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
43266733Speter
44266733Speternamespace __gnu_pbds
45266733Speter{
46266733Speter  namespace detail
47266733Speter  {
48266733Speter    /// Entry compare, primary template.
49266733Speter    template<typename _VTp, typename Cmp_Fn, typename _Alloc, bool No_Throw>
50266733Speter      struct entry_cmp;
51266733Speter
52266733Speter    /// Specialization, true.
53266733Speter    template<typename _VTp, typename Cmp_Fn, typename _Alloc>
54266733Speter      struct entry_cmp<_VTp, Cmp_Fn, _Alloc, true>
55266733Speter      {
56266733Speter	/// Compare.
57266733Speter	typedef Cmp_Fn 						type;
58266733Speter      };
59266733Speter
60266733Speter    /// Specialization, false.
61266733Speter    template<typename _VTp, typename Cmp_Fn, typename _Alloc>
62266733Speter      struct entry_cmp<_VTp, Cmp_Fn, _Alloc, false>
63266733Speter      {
64266733Speter      private:
65266733Speter	typedef rebind_traits<_Alloc, _VTp>		__rebind_v;
66266733Speter
67266733Speter      public:
68266733Speter	typedef typename __rebind_v::const_pointer	entry;
69266733Speter
70266733Speter	/// Compare plus entry.
71266733Speter	struct type : public Cmp_Fn
72266733Speter	{
73266733Speter	  type() { }
74266733Speter
75266733Speter	  type(const Cmp_Fn& other) : Cmp_Fn(other) { }
76266733Speter
77266733Speter	  bool
78266733Speter	  operator()(entry lhs, entry rhs) const
79266733Speter	  { return Cmp_Fn::operator()(*lhs, *rhs); }
80266733Speter	};
81266733Speter      };
82266733Speter  } // namespace detail
83266733Speter} // namespace __gnu_pbds
84266733Speter
85266733Speter#endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
86266733Speter