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 BHO_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP
  11. #define BHO_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP
  12. #ifndef BHO_CONFIG_HPP
  13. # include <asio2/bho/config.hpp>
  14. #endif
  15. #if defined(BHO_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <asio2/bho/move/detail/iterator_traits.hpp>
  19. #include <asio2/bho/move/detail/to_raw_pointer.hpp>
  20. #include <asio2/bho/move/detail/pointer_element.hpp>
  21. namespace bho {
  22. namespace movelib {
  23. namespace detail {
  24. template <class T>
  25. BHO_MOVE_FORCEINLINE T* iterator_to_pointer(T* i)
  26. { return i; }
  27. template <class Iterator>
  28. BHO_MOVE_FORCEINLINE typename bho::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 bho::movelib::iterator_traits<Iterator>::pointer pointer;
  35. typedef typename bho::movelib::pointer_element<pointer>::type element_type;
  36. typedef element_type* type;
  37. };
  38. } //namespace detail {
  39. template <class Iterator>
  40. BHO_MOVE_FORCEINLINE typename bho::movelib::detail::iterator_to_element_ptr<Iterator>::type
  41. iterator_to_raw_pointer(const Iterator &i)
  42. {
  43. return ::bho::movelib::to_raw_pointer
  44. ( ::bho::movelib::detail::iterator_to_pointer(i) );
  45. }
  46. } //namespace movelib {
  47. } //namespace bho {
  48. #endif //#ifndef BHO_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP