converter.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright 2003-2013 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_CONVERTER_HPP
  9. #define BOOST_MULTI_INDEX_DETAIL_CONVERTER_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. namespace boost{
  14. namespace multi_index{
  15. namespace detail{
  16. /* converter offers means to access indices of a given multi_index_container
  17. * and for convertibilty between index iterators, so providing a
  18. * localized access point for get() and project() functions.
  19. */
  20. template<typename MultiIndexContainer,typename Index>
  21. struct converter
  22. {
  23. static const Index& index(const MultiIndexContainer& x){return x;}
  24. static Index& index(MultiIndexContainer& x){return x;}
  25. static typename Index::const_iterator const_iterator(
  26. const MultiIndexContainer& x,typename MultiIndexContainer::node_type* node)
  27. {
  28. return x.Index::make_iterator(node);
  29. }
  30. static typename Index::iterator iterator(
  31. MultiIndexContainer& x,typename MultiIndexContainer::node_type* node)
  32. {
  33. return x.Index::make_iterator(node);
  34. }
  35. };
  36. } /* namespace multi_index::detail */
  37. } /* namespace multi_index */
  38. } /* namespace boost */
  39. #endif