value_compare.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/multi_index for library home page.
  7. */
  8. #ifndef BOOST_MULTI_INDEX_DETAIL_VALUE_COMPARE_HPP
  9. #define BOOST_MULTI_INDEX_DETAIL_VALUE_COMPARE_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/call_traits.hpp>
  15. namespace boost{
  16. namespace multi_index{
  17. namespace detail{
  18. template<typename Value,typename KeyFromValue,typename Compare>
  19. struct value_comparison
  20. {
  21. typedef Value first_argument_type;
  22. typedef Value second_argument_type;
  23. typedef bool result_type;
  24. value_comparison(
  25. const KeyFromValue& key_=KeyFromValue(),const Compare& comp_=Compare()):
  26. key(key_),comp(comp_)
  27. {
  28. }
  29. bool operator()(
  30. typename call_traits<Value>::param_type x,
  31. typename call_traits<Value>::param_type y)const
  32. {
  33. return comp(key(x),key(y));
  34. }
  35. private:
  36. KeyFromValue key;
  37. Compare comp;
  38. };
  39. } /* namespace multi_index::detail */
  40. } /* namespace multi_index */
  41. } /* namespace boost */
  42. #endif