priority_compare.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2008
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP
  13. #define BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP
  14. #include <boost/intrusive/detail/config_begin.hpp>
  15. #include <boost/intrusive/detail/workaround.hpp>
  16. #include <boost/intrusive/intrusive_fwd.hpp>
  17. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>
  18. #if defined(BOOST_HAS_PRAGMA_ONCE)
  19. # pragma once
  20. #endif
  21. namespace boost {
  22. namespace intrusive {
  23. /// @cond
  24. template<class U>
  25. void priority_order();
  26. /// @endcond
  27. template <class T = void>
  28. struct priority_compare
  29. {
  30. //Compatibility with std::binary_function
  31. typedef T first_argument_type;
  32. typedef T second_argument_type;
  33. typedef bool result_type;
  34. BOOST_INTRUSIVE_FORCEINLINE bool operator()(const T &val, const T &val2) const
  35. {
  36. return priority_order(val, val2);
  37. }
  38. };
  39. template <>
  40. struct priority_compare<void>
  41. {
  42. template<class T, class U>
  43. BOOST_INTRUSIVE_FORCEINLINE bool operator()(const T &t, const U &u) const
  44. {
  45. return priority_order(t, u);
  46. }
  47. };
  48. /// @cond
  49. template<class PrioComp, class T>
  50. struct get_prio_comp
  51. {
  52. typedef PrioComp type;
  53. };
  54. template<class T>
  55. struct get_prio_comp<void, T>
  56. {
  57. typedef ::boost::intrusive::priority_compare<T> type;
  58. };
  59. /// @endcond
  60. } //namespace intrusive
  61. } //namespace boost
  62. #include <boost/intrusive/detail/config_end.hpp>
  63. #endif //BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP