converter.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright 2003-2020 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,
  27. typename MultiIndexContainer::final_node_type* node)
  28. {
  29. return x.Index::make_iterator(node);
  30. }
  31. static typename Index::iterator iterator(
  32. MultiIndexContainer& x,
  33. typename MultiIndexContainer::final_node_type* node)
  34. {
  35. return x.Index::make_iterator(node);
  36. }
  37. };
  38. } /* namespace multi_index::detail */
  39. } /* namespace multi_index */
  40. } /* namespace boost */
  41. #endif