map_entry.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef MAP_ENTRY_DWA2002118_HPP
  6. # define MAP_ENTRY_DWA2002118_HPP
  7. namespace boost { namespace python { namespace detail {
  8. // A trivial type that works well as the value_type of associative
  9. // vector maps
  10. template <class Key, class Value>
  11. struct map_entry
  12. {
  13. map_entry() {}
  14. map_entry(Key k) : key(k), value() {}
  15. map_entry(Key k, Value v) : key(k), value(v) {}
  16. bool operator<(map_entry const& rhs) const
  17. {
  18. return this->key < rhs.key;
  19. }
  20. Key key;
  21. Value value;
  22. };
  23. template <class Key, class Value>
  24. bool operator<(map_entry<Key,Value> const& e, Key const& k)
  25. {
  26. return e.key < k;
  27. }
  28. template <class Key, class Value>
  29. bool operator<(Key const& k, map_entry<Key,Value> const& e)
  30. {
  31. return k < e.key;
  32. }
  33. }}} // namespace boost::python::detail
  34. #endif // MAP_ENTRY_DWA2002118_HPP