iterator_to_raw_pointer.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP
  11. #define BOOST_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/move/detail/iterator_traits.hpp>
  19. #include <boost/move/detail/to_raw_pointer.hpp>
  20. #include <boost/move/detail/pointer_element.hpp>
  21. namespace boost {
  22. namespace movelib {
  23. namespace detail {
  24. template <class T>
  25. inline T* iterator_to_pointer(T* i)
  26. { return i; }
  27. template <class Iterator>
  28. inline typename boost::movelib::iterator_traits<Iterator>::pointer
  29. iterator_to_pointer(const Iterator &i)
  30. { return i.operator->(); }
  31. template <class Iterator>
  32. struct iterator_to_element_ptr
  33. {
  34. typedef typename boost::movelib::iterator_traits<Iterator>::pointer pointer;
  35. typedef typename boost::movelib::pointer_element<pointer>::type element_type;
  36. typedef element_type* type;
  37. };
  38. } //namespace detail {
  39. template <class Iterator>
  40. inline typename boost::movelib::detail::iterator_to_element_ptr<Iterator>::type
  41. iterator_to_raw_pointer(const Iterator &i)
  42. {
  43. return ::boost::movelib::to_raw_pointer
  44. ( ::boost::movelib::detail::iterator_to_pointer(i) );
  45. }
  46. } //namespace movelib {
  47. } //namespace boost {
  48. #endif //#ifndef BOOST_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP