| 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_BACK_INSERT_ITERATOR_H |
| 11 |
#define _LIBCPP___CXX03___ITERATOR_BACK_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 |
_LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 30 |
template <class _Container> |
| 31 |
class _LIBCPP_TEMPLATE_VIS back_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> { |
| 32 |
_LIBCPP_SUPPRESS_DEPRECATED_POP |
| 33 |
|
| 34 |
protected: |
| 35 |
_Container* container; |
| 36 |
|
| 37 |
public: |
| 38 |
typedef output_iterator_tag iterator_category; |
| 39 |
typedef void value_type; |
| 40 |
typedef void difference_type; |
| 41 |
typedef void pointer; |
| 42 |
typedef void reference; |
| 43 |
typedef _Container container_type; |
| 44 |
|
| 45 |
_LIBCPP_HIDE_FROM_ABI explicit back_insert_iterator(_Container& __x) : container(std::addressof(__x)) {} |
| 46 |
_LIBCPP_HIDE_FROM_ABI back_insert_iterator& operator=(const typename _Container::value_type& __value) { |
| 47 |
container->push_back(__value); |
| 48 |
return *this; |
| 49 |
} |
| 50 |
_LIBCPP_HIDE_FROM_ABI back_insert_iterator& operator*() { return *this; } |
| 51 |
_LIBCPP_HIDE_FROM_ABI back_insert_iterator& operator++() { return *this; } |
| 52 |
_LIBCPP_HIDE_FROM_ABI back_insert_iterator operator++(int) { return *this; } |
| 53 |
|
| 54 |
_LIBCPP_HIDE_FROM_ABI _Container* __get_container() const { return container; } |
| 55 |
}; |
| 56 |
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(back_insert_iterator); |
| 57 |
|
| 58 |
template <class _Container> |
| 59 |
inline _LIBCPP_HIDE_FROM_ABI back_insert_iterator<_Container> back_inserter(_Container& __x) { |
| 60 |
return back_insert_iterator<_Container>(__x); |
| 61 |
} |
| 62 |
|
| 63 |
_LIBCPP_END_NAMESPACE_STD |
| 64 |
|
| 65 |
_LIBCPP_POP_MACROS |
| 66 |
|
| 67 |
#endif // _LIBCPP___CXX03___ITERATOR_BACK_INSERT_ITERATOR_H |