iterator.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2014-2014.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/container for documentation.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_CONTAINER_DETAIL_ITERATOR_HPP
  13. #define BOOST_CONTAINER_DETAIL_ITERATOR_HPP
  14. #ifndef BOOST_CONFIG_HPP
  15. # include <boost/config.hpp>
  16. #endif
  17. #if defined(BOOST_HAS_PRAGMA_ONCE)
  18. # pragma once
  19. #endif
  20. #include <boost/intrusive/detail/iterator.hpp>
  21. #include <boost/move/utility_core.hpp>
  22. #include <boost/container/detail/mpl.hpp>
  23. namespace boost {
  24. namespace container {
  25. using ::boost::intrusive::iterator_traits;
  26. using ::boost::intrusive::iter_difference;
  27. using ::boost::intrusive::iter_category;
  28. using ::boost::intrusive::iter_value;
  29. using ::boost::intrusive::iter_size;
  30. using ::boost::intrusive::iterator_distance;
  31. using ::boost::intrusive::iterator_udistance;
  32. using ::boost::intrusive::iterator_advance;
  33. using ::boost::intrusive::iterator_uadvance;
  34. using ::boost::intrusive::make_iterator_advance;
  35. using ::boost::intrusive::make_iterator_uadvance;
  36. using ::boost::intrusive::iterator;
  37. using ::boost::intrusive::iterator_enable_if_tag;
  38. using ::boost::intrusive::iterator_disable_if_tag;
  39. using ::boost::intrusive::iterator_arrow_result;
  40. template <class Container>
  41. class back_emplacer
  42. {
  43. private:
  44. Container& container;
  45. public:
  46. typedef std::output_iterator_tag iterator_category;
  47. typedef void value_type;
  48. typedef void difference_type;
  49. typedef void pointer;
  50. typedef void reference;
  51. back_emplacer(Container& x)
  52. : container(x)
  53. {}
  54. template<class U>
  55. back_emplacer& operator=(BOOST_FWD_REF(U) value)
  56. {
  57. container.emplace_back(boost::forward<U>(value));
  58. return *this;
  59. }
  60. back_emplacer& operator*() { return *this; }
  61. back_emplacer& operator++() { return *this; }
  62. back_emplacer& operator++(int){ return *this; }
  63. };
  64. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  65. template<class InputIterator>
  66. using it_based_non_const_first_type_t = typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type;
  67. template<class InputIterator>
  68. using it_based_const_first_type_t = const typename dtl::remove_const<typename iterator_traits<InputIterator>::value_type::first_type>::type;
  69. template<class InputIterator>
  70. using it_based_second_type_t = typename iterator_traits<InputIterator>::value_type::second_type;
  71. template<class InputIterator>
  72. using it_based_value_type_t = typename iterator_traits<InputIterator>::value_type;
  73. #endif
  74. } //namespace container {
  75. } //namespace boost {
  76. #endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP