Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:52

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
0011 #define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
0012 
0013 #include <__config>
0014 #include <__cstddef/ptrdiff_t.h>
0015 #include <__iterator/iterator.h>
0016 #include <__iterator/iterator_traits.h>
0017 #include <__memory/addressof.h>
0018 #include <__utility/move.h>
0019 
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 #  pragma GCC system_header
0022 #endif
0023 
0024 _LIBCPP_PUSH_MACROS
0025 #include <__undef_macros>
0026 
0027 _LIBCPP_BEGIN_NAMESPACE_STD
0028 
0029 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
0030 template <class _Container>
0031 class _LIBCPP_TEMPLATE_VIS back_insert_iterator
0032 #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
0033     : public iterator<output_iterator_tag, void, void, void, void>
0034 #endif
0035 {
0036   _LIBCPP_SUPPRESS_DEPRECATED_POP
0037 
0038 protected:
0039   _Container* container;
0040 
0041 public:
0042   typedef output_iterator_tag iterator_category;
0043   typedef void value_type;
0044 #if _LIBCPP_STD_VER >= 20
0045   typedef ptrdiff_t difference_type;
0046 #else
0047   typedef void difference_type;
0048 #endif
0049   typedef void pointer;
0050   typedef void reference;
0051   typedef _Container container_type;
0052 
0053   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit back_insert_iterator(_Container& __x)
0054       : container(std::addressof(__x)) {}
0055   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator&
0056   operator=(const typename _Container::value_type& __value) {
0057     container->push_back(__value);
0058     return *this;
0059   }
0060 #ifndef _LIBCPP_CXX03_LANG
0061   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator&
0062   operator=(typename _Container::value_type&& __value) {
0063     container->push_back(std::move(__value));
0064     return *this;
0065   }
0066 #endif // _LIBCPP_CXX03_LANG
0067   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() { return *this; }
0068   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator++() { return *this; }
0069   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator operator++(int) { return *this; }
0070 
0071   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Container* __get_container() const { return container; }
0072 };
0073 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(back_insert_iterator);
0074 
0075 template <class _Container>
0076 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator<_Container>
0077 back_inserter(_Container& __x) {
0078   return back_insert_iterator<_Container>(__x);
0079 }
0080 
0081 _LIBCPP_END_NAMESPACE_STD
0082 
0083 _LIBCPP_POP_MACROS
0084 
0085 #endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H