Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP___CXX03___ITERATOR_INSERT_ITERATOR_H |
| 11 | #define _LIBCPP___CXX03___ITERATOR_INSERT_ITERATOR_H |
| 12 | |
| 13 | #include <__cxx03/__config> |
| 14 | #include <__cxx03/__iterator/iterator.h> |
| 15 | #include <__cxx03/__iterator/iterator_traits.h> |
| 16 | #include <__cxx03/__memory/addressof.h> |
| 17 | #include <__cxx03/__utility/move.h> |
| 18 | #include <__cxx03/cstddef> |
| 19 | |
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header |
| 22 | #endif |
| 23 | |
| 24 | _LIBCPP_PUSH_MACROS |
| 25 | #include <__cxx03/__undef_macros> |
| 26 | |
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | |
| 29 | template <class _Container> |
| 30 | using __insert_iterator_iter_t = typename _Container::iterator; |
| 31 | |
| 32 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 33 | template <class _Container> |
| 34 | class _LIBCPP_TEMPLATE_VIS insert_iterator : public iterator<output_iterator_tag, void, void, void, void> { |
| 35 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 36 | |
| 37 | protected: |
| 38 | _Container* container; |
| 39 | __insert_iterator_iter_t<_Container> iter; |
| 40 | |
| 41 | public: |
| 42 | typedef output_iterator_tag iterator_category; |
| 43 | typedef void value_type; |
| 44 | typedef void difference_type; |
| 45 | typedef void pointer; |
| 46 | typedef void reference; |
| 47 | typedef _Container container_type; |
| 48 | |
| 49 | _LIBCPP_HIDE_FROM_ABI insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) |
| 50 | : container(std::addressof(__x)), iter(__i) {} |
| 51 | _LIBCPP_HIDE_FROM_ABI insert_iterator& operator=(const typename _Container::value_type& __value) { |
| 52 | iter = container->insert(iter, __value); |
| 53 | ++iter; |
| 54 | return *this; |
| 55 | } |
| 56 | _LIBCPP_HIDE_FROM_ABI insert_iterator& operator*() { return *this; } |
| 57 | _LIBCPP_HIDE_FROM_ABI insert_iterator& operator++() { return *this; } |
| 58 | _LIBCPP_HIDE_FROM_ABI insert_iterator& operator++(int) { return *this; } |
| 59 | }; |
| 60 | |
| 61 | template <class _Container> |
| 62 | inline _LIBCPP_HIDE_FROM_ABI insert_iterator<_Container> |
| 63 | inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) { |
| 64 | return insert_iterator<_Container>(__x, __i); |
| 65 | } |
| 66 | |
| 67 | _LIBCPP_END_NAMESPACE_STD |
| 68 | |
| 69 | _LIBCPP_POP_MACROS |
| 70 | |
| 71 | #endif // _LIBCPP___CXX03___ITERATOR_INSERT_ITERATOR_H |
| 72 |
Warning: This file is not a C or C++ file. It does not have highlighting.
