priority_compare.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. namespace adldft {
  25. template<class T, class U>
  26. inline bool priority_order(const T &t, const U &u)
  27. { return t < u; }
  28. } //namespace adldft {
  29. /// @endcond
  30. template <class T = void>
  31. struct priority_compare
  32. {
  33. //Compatibility with std::binary_function
  34. typedef T first_argument_type;
  35. typedef T second_argument_type;
  36. typedef bool result_type;
  37. inline bool operator()(const T &val, const T &val2) const
  38. {
  39. using adldft::priority_order;
  40. return priority_order(val, val2);
  41. }
  42. };
  43. template <>
  44. struct priority_compare<void>
  45. {
  46. template<class T, class U>
  47. inline bool operator()(const T &t, const U &u) const
  48. {
  49. using adldft::priority_order;
  50. return priority_order(t, u);
  51. }
  52. };
  53. /// @cond
  54. template<class PrioComp, class T>
  55. struct get_prio_comp
  56. {
  57. typedef PrioComp type;
  58. };
  59. template<class T>
  60. struct get_prio_comp<void, T>
  61. {
  62. typedef ::boost::intrusive::priority_compare<T> type;
  63. };
  64. /// @endcond
  65. } //namespace intrusive
  66. } //namespace boost
  67. #include <boost/intrusive/detail/config_end.hpp>
  68. #endif //BOOST_INTRUSIVE_PRIORITY_COMPARE_HPP