1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*- 2*58b9f456SAndroid Build Coastguard Worker//===------------------------------ vector --------------------------------===// 3*58b9f456SAndroid Build Coastguard Worker// 4*58b9f456SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 5*58b9f456SAndroid Build Coastguard Worker// 6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open 7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details. 8*58b9f456SAndroid Build Coastguard Worker// 9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 10*58b9f456SAndroid Build Coastguard Worker 11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_VECTOR 12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_VECTOR 13*58b9f456SAndroid Build Coastguard Worker 14*58b9f456SAndroid Build Coastguard Worker/* 15*58b9f456SAndroid Build Coastguard Worker vector synopsis 16*58b9f456SAndroid Build Coastguard Worker 17*58b9f456SAndroid Build Coastguard Workernamespace std 18*58b9f456SAndroid Build Coastguard Worker{ 19*58b9f456SAndroid Build Coastguard Worker 20*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator = allocator<T> > 21*58b9f456SAndroid Build Coastguard Workerclass vector 22*58b9f456SAndroid Build Coastguard Worker{ 23*58b9f456SAndroid Build Coastguard Workerpublic: 24*58b9f456SAndroid Build Coastguard Worker typedef T value_type; 25*58b9f456SAndroid Build Coastguard Worker typedef Allocator allocator_type; 26*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::reference reference; 27*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::const_reference const_reference; 28*58b9f456SAndroid Build Coastguard Worker typedef implementation-defined iterator; 29*58b9f456SAndroid Build Coastguard Worker typedef implementation-defined const_iterator; 30*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::size_type size_type; 31*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::difference_type difference_type; 32*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::pointer pointer; 33*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::const_pointer const_pointer; 34*58b9f456SAndroid Build Coastguard Worker typedef std::reverse_iterator<iterator> reverse_iterator; 35*58b9f456SAndroid Build Coastguard Worker typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 36*58b9f456SAndroid Build Coastguard Worker 37*58b9f456SAndroid Build Coastguard Worker vector() 38*58b9f456SAndroid Build Coastguard Worker noexcept(is_nothrow_default_constructible<allocator_type>::value); 39*58b9f456SAndroid Build Coastguard Worker explicit vector(const allocator_type&); 40*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type n); 41*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type n, const allocator_type&); // C++14 42*58b9f456SAndroid Build Coastguard Worker vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); 43*58b9f456SAndroid Build Coastguard Worker template <class InputIterator> 44*58b9f456SAndroid Build Coastguard Worker vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); 45*58b9f456SAndroid Build Coastguard Worker vector(const vector& x); 46*58b9f456SAndroid Build Coastguard Worker vector(vector&& x) 47*58b9f456SAndroid Build Coastguard Worker noexcept(is_nothrow_move_constructible<allocator_type>::value); 48*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> il); 49*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> il, const allocator_type& a); 50*58b9f456SAndroid Build Coastguard Worker ~vector(); 51*58b9f456SAndroid Build Coastguard Worker vector& operator=(const vector& x); 52*58b9f456SAndroid Build Coastguard Worker vector& operator=(vector&& x) 53*58b9f456SAndroid Build Coastguard Worker noexcept( 54*58b9f456SAndroid Build Coastguard Worker allocator_type::propagate_on_container_move_assignment::value || 55*58b9f456SAndroid Build Coastguard Worker allocator_type::is_always_equal::value); // C++17 56*58b9f456SAndroid Build Coastguard Worker vector& operator=(initializer_list<value_type> il); 57*58b9f456SAndroid Build Coastguard Worker template <class InputIterator> 58*58b9f456SAndroid Build Coastguard Worker void assign(InputIterator first, InputIterator last); 59*58b9f456SAndroid Build Coastguard Worker void assign(size_type n, const value_type& u); 60*58b9f456SAndroid Build Coastguard Worker void assign(initializer_list<value_type> il); 61*58b9f456SAndroid Build Coastguard Worker 62*58b9f456SAndroid Build Coastguard Worker allocator_type get_allocator() const noexcept; 63*58b9f456SAndroid Build Coastguard Worker 64*58b9f456SAndroid Build Coastguard Worker iterator begin() noexcept; 65*58b9f456SAndroid Build Coastguard Worker const_iterator begin() const noexcept; 66*58b9f456SAndroid Build Coastguard Worker iterator end() noexcept; 67*58b9f456SAndroid Build Coastguard Worker const_iterator end() const noexcept; 68*58b9f456SAndroid Build Coastguard Worker 69*58b9f456SAndroid Build Coastguard Worker reverse_iterator rbegin() noexcept; 70*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rbegin() const noexcept; 71*58b9f456SAndroid Build Coastguard Worker reverse_iterator rend() noexcept; 72*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rend() const noexcept; 73*58b9f456SAndroid Build Coastguard Worker 74*58b9f456SAndroid Build Coastguard Worker const_iterator cbegin() const noexcept; 75*58b9f456SAndroid Build Coastguard Worker const_iterator cend() const noexcept; 76*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crbegin() const noexcept; 77*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crend() const noexcept; 78*58b9f456SAndroid Build Coastguard Worker 79*58b9f456SAndroid Build Coastguard Worker size_type size() const noexcept; 80*58b9f456SAndroid Build Coastguard Worker size_type max_size() const noexcept; 81*58b9f456SAndroid Build Coastguard Worker size_type capacity() const noexcept; 82*58b9f456SAndroid Build Coastguard Worker bool empty() const noexcept; 83*58b9f456SAndroid Build Coastguard Worker void reserve(size_type n); 84*58b9f456SAndroid Build Coastguard Worker void shrink_to_fit() noexcept; 85*58b9f456SAndroid Build Coastguard Worker 86*58b9f456SAndroid Build Coastguard Worker reference operator[](size_type n); 87*58b9f456SAndroid Build Coastguard Worker const_reference operator[](size_type n) const; 88*58b9f456SAndroid Build Coastguard Worker reference at(size_type n); 89*58b9f456SAndroid Build Coastguard Worker const_reference at(size_type n) const; 90*58b9f456SAndroid Build Coastguard Worker 91*58b9f456SAndroid Build Coastguard Worker reference front(); 92*58b9f456SAndroid Build Coastguard Worker const_reference front() const; 93*58b9f456SAndroid Build Coastguard Worker reference back(); 94*58b9f456SAndroid Build Coastguard Worker const_reference back() const; 95*58b9f456SAndroid Build Coastguard Worker 96*58b9f456SAndroid Build Coastguard Worker value_type* data() noexcept; 97*58b9f456SAndroid Build Coastguard Worker const value_type* data() const noexcept; 98*58b9f456SAndroid Build Coastguard Worker 99*58b9f456SAndroid Build Coastguard Worker void push_back(const value_type& x); 100*58b9f456SAndroid Build Coastguard Worker void push_back(value_type&& x); 101*58b9f456SAndroid Build Coastguard Worker template <class... Args> 102*58b9f456SAndroid Build Coastguard Worker reference emplace_back(Args&&... args); // reference in C++17 103*58b9f456SAndroid Build Coastguard Worker void pop_back(); 104*58b9f456SAndroid Build Coastguard Worker 105*58b9f456SAndroid Build Coastguard Worker template <class... Args> iterator emplace(const_iterator position, Args&&... args); 106*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, const value_type& x); 107*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, value_type&& x); 108*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, size_type n, const value_type& x); 109*58b9f456SAndroid Build Coastguard Worker template <class InputIterator> 110*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, InputIterator first, InputIterator last); 111*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, initializer_list<value_type> il); 112*58b9f456SAndroid Build Coastguard Worker 113*58b9f456SAndroid Build Coastguard Worker iterator erase(const_iterator position); 114*58b9f456SAndroid Build Coastguard Worker iterator erase(const_iterator first, const_iterator last); 115*58b9f456SAndroid Build Coastguard Worker 116*58b9f456SAndroid Build Coastguard Worker void clear() noexcept; 117*58b9f456SAndroid Build Coastguard Worker 118*58b9f456SAndroid Build Coastguard Worker void resize(size_type sz); 119*58b9f456SAndroid Build Coastguard Worker void resize(size_type sz, const value_type& c); 120*58b9f456SAndroid Build Coastguard Worker 121*58b9f456SAndroid Build Coastguard Worker void swap(vector&) 122*58b9f456SAndroid Build Coastguard Worker noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || 123*58b9f456SAndroid Build Coastguard Worker allocator_traits<allocator_type>::is_always_equal::value); // C++17 124*58b9f456SAndroid Build Coastguard Worker 125*58b9f456SAndroid Build Coastguard Worker bool __invariants() const; 126*58b9f456SAndroid Build Coastguard Worker}; 127*58b9f456SAndroid Build Coastguard Worker 128*58b9f456SAndroid Build Coastguard Workertemplate <class Allocator = allocator<T> > 129*58b9f456SAndroid Build Coastguard Workerclass vector<bool, Allocator> 130*58b9f456SAndroid Build Coastguard Worker{ 131*58b9f456SAndroid Build Coastguard Workerpublic: 132*58b9f456SAndroid Build Coastguard Worker typedef bool value_type; 133*58b9f456SAndroid Build Coastguard Worker typedef Allocator allocator_type; 134*58b9f456SAndroid Build Coastguard Worker typedef implementation-defined iterator; 135*58b9f456SAndroid Build Coastguard Worker typedef implementation-defined const_iterator; 136*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::size_type size_type; 137*58b9f456SAndroid Build Coastguard Worker typedef typename allocator_type::difference_type difference_type; 138*58b9f456SAndroid Build Coastguard Worker typedef iterator pointer; 139*58b9f456SAndroid Build Coastguard Worker typedef const_iterator const_pointer; 140*58b9f456SAndroid Build Coastguard Worker typedef std::reverse_iterator<iterator> reverse_iterator; 141*58b9f456SAndroid Build Coastguard Worker typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 142*58b9f456SAndroid Build Coastguard Worker 143*58b9f456SAndroid Build Coastguard Worker class reference 144*58b9f456SAndroid Build Coastguard Worker { 145*58b9f456SAndroid Build Coastguard Worker public: 146*58b9f456SAndroid Build Coastguard Worker reference(const reference&) noexcept; 147*58b9f456SAndroid Build Coastguard Worker operator bool() const noexcept; 148*58b9f456SAndroid Build Coastguard Worker reference& operator=(const bool x) noexcept; 149*58b9f456SAndroid Build Coastguard Worker reference& operator=(const reference& x) noexcept; 150*58b9f456SAndroid Build Coastguard Worker iterator operator&() const noexcept; 151*58b9f456SAndroid Build Coastguard Worker void flip() noexcept; 152*58b9f456SAndroid Build Coastguard Worker }; 153*58b9f456SAndroid Build Coastguard Worker 154*58b9f456SAndroid Build Coastguard Worker class const_reference 155*58b9f456SAndroid Build Coastguard Worker { 156*58b9f456SAndroid Build Coastguard Worker public: 157*58b9f456SAndroid Build Coastguard Worker const_reference(const reference&) noexcept; 158*58b9f456SAndroid Build Coastguard Worker operator bool() const noexcept; 159*58b9f456SAndroid Build Coastguard Worker const_iterator operator&() const noexcept; 160*58b9f456SAndroid Build Coastguard Worker }; 161*58b9f456SAndroid Build Coastguard Worker 162*58b9f456SAndroid Build Coastguard Worker vector() 163*58b9f456SAndroid Build Coastguard Worker noexcept(is_nothrow_default_constructible<allocator_type>::value); 164*58b9f456SAndroid Build Coastguard Worker explicit vector(const allocator_type&); 165*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 166*58b9f456SAndroid Build Coastguard Worker vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); 167*58b9f456SAndroid Build Coastguard Worker template <class InputIterator> 168*58b9f456SAndroid Build Coastguard Worker vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); 169*58b9f456SAndroid Build Coastguard Worker vector(const vector& x); 170*58b9f456SAndroid Build Coastguard Worker vector(vector&& x) 171*58b9f456SAndroid Build Coastguard Worker noexcept(is_nothrow_move_constructible<allocator_type>::value); 172*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> il); 173*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> il, const allocator_type& a); 174*58b9f456SAndroid Build Coastguard Worker ~vector(); 175*58b9f456SAndroid Build Coastguard Worker vector& operator=(const vector& x); 176*58b9f456SAndroid Build Coastguard Worker vector& operator=(vector&& x) 177*58b9f456SAndroid Build Coastguard Worker noexcept( 178*58b9f456SAndroid Build Coastguard Worker allocator_type::propagate_on_container_move_assignment::value || 179*58b9f456SAndroid Build Coastguard Worker allocator_type::is_always_equal::value); // C++17 180*58b9f456SAndroid Build Coastguard Worker vector& operator=(initializer_list<value_type> il); 181*58b9f456SAndroid Build Coastguard Worker template <class InputIterator> 182*58b9f456SAndroid Build Coastguard Worker void assign(InputIterator first, InputIterator last); 183*58b9f456SAndroid Build Coastguard Worker void assign(size_type n, const value_type& u); 184*58b9f456SAndroid Build Coastguard Worker void assign(initializer_list<value_type> il); 185*58b9f456SAndroid Build Coastguard Worker 186*58b9f456SAndroid Build Coastguard Worker allocator_type get_allocator() const noexcept; 187*58b9f456SAndroid Build Coastguard Worker 188*58b9f456SAndroid Build Coastguard Worker iterator begin() noexcept; 189*58b9f456SAndroid Build Coastguard Worker const_iterator begin() const noexcept; 190*58b9f456SAndroid Build Coastguard Worker iterator end() noexcept; 191*58b9f456SAndroid Build Coastguard Worker const_iterator end() const noexcept; 192*58b9f456SAndroid Build Coastguard Worker 193*58b9f456SAndroid Build Coastguard Worker reverse_iterator rbegin() noexcept; 194*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rbegin() const noexcept; 195*58b9f456SAndroid Build Coastguard Worker reverse_iterator rend() noexcept; 196*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rend() const noexcept; 197*58b9f456SAndroid Build Coastguard Worker 198*58b9f456SAndroid Build Coastguard Worker const_iterator cbegin() const noexcept; 199*58b9f456SAndroid Build Coastguard Worker const_iterator cend() const noexcept; 200*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crbegin() const noexcept; 201*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crend() const noexcept; 202*58b9f456SAndroid Build Coastguard Worker 203*58b9f456SAndroid Build Coastguard Worker size_type size() const noexcept; 204*58b9f456SAndroid Build Coastguard Worker size_type max_size() const noexcept; 205*58b9f456SAndroid Build Coastguard Worker size_type capacity() const noexcept; 206*58b9f456SAndroid Build Coastguard Worker bool empty() const noexcept; 207*58b9f456SAndroid Build Coastguard Worker void reserve(size_type n); 208*58b9f456SAndroid Build Coastguard Worker void shrink_to_fit() noexcept; 209*58b9f456SAndroid Build Coastguard Worker 210*58b9f456SAndroid Build Coastguard Worker reference operator[](size_type n); 211*58b9f456SAndroid Build Coastguard Worker const_reference operator[](size_type n) const; 212*58b9f456SAndroid Build Coastguard Worker reference at(size_type n); 213*58b9f456SAndroid Build Coastguard Worker const_reference at(size_type n) const; 214*58b9f456SAndroid Build Coastguard Worker 215*58b9f456SAndroid Build Coastguard Worker reference front(); 216*58b9f456SAndroid Build Coastguard Worker const_reference front() const; 217*58b9f456SAndroid Build Coastguard Worker reference back(); 218*58b9f456SAndroid Build Coastguard Worker const_reference back() const; 219*58b9f456SAndroid Build Coastguard Worker 220*58b9f456SAndroid Build Coastguard Worker void push_back(const value_type& x); 221*58b9f456SAndroid Build Coastguard Worker template <class... Args> reference emplace_back(Args&&... args); // C++14; reference in C++17 222*58b9f456SAndroid Build Coastguard Worker void pop_back(); 223*58b9f456SAndroid Build Coastguard Worker 224*58b9f456SAndroid Build Coastguard Worker template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14 225*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, const value_type& x); 226*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, size_type n, const value_type& x); 227*58b9f456SAndroid Build Coastguard Worker template <class InputIterator> 228*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, InputIterator first, InputIterator last); 229*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator position, initializer_list<value_type> il); 230*58b9f456SAndroid Build Coastguard Worker 231*58b9f456SAndroid Build Coastguard Worker iterator erase(const_iterator position); 232*58b9f456SAndroid Build Coastguard Worker iterator erase(const_iterator first, const_iterator last); 233*58b9f456SAndroid Build Coastguard Worker 234*58b9f456SAndroid Build Coastguard Worker void clear() noexcept; 235*58b9f456SAndroid Build Coastguard Worker 236*58b9f456SAndroid Build Coastguard Worker void resize(size_type sz); 237*58b9f456SAndroid Build Coastguard Worker void resize(size_type sz, value_type x); 238*58b9f456SAndroid Build Coastguard Worker 239*58b9f456SAndroid Build Coastguard Worker void swap(vector&) 240*58b9f456SAndroid Build Coastguard Worker noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || 241*58b9f456SAndroid Build Coastguard Worker allocator_traits<allocator_type>::is_always_equal::value); // C++17 242*58b9f456SAndroid Build Coastguard Worker void flip() noexcept; 243*58b9f456SAndroid Build Coastguard Worker 244*58b9f456SAndroid Build Coastguard Worker bool __invariants() const; 245*58b9f456SAndroid Build Coastguard Worker}; 246*58b9f456SAndroid Build Coastguard Worker 247*58b9f456SAndroid Build Coastguard Workertemplate <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> 248*58b9f456SAndroid Build Coastguard Worker vector(InputIterator, InputIterator, Allocator = Allocator()) 249*58b9f456SAndroid Build Coastguard Worker -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; 250*58b9f456SAndroid Build Coastguard Worker 251*58b9f456SAndroid Build Coastguard Workertemplate <class Allocator> struct hash<std::vector<bool, Allocator>>; 252*58b9f456SAndroid Build Coastguard Worker 253*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y); 254*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y); 255*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); 256*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y); 257*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); 258*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); 259*58b9f456SAndroid Build Coastguard Worker 260*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator> 261*58b9f456SAndroid Build Coastguard Workervoid swap(vector<T,Allocator>& x, vector<T,Allocator>& y) 262*58b9f456SAndroid Build Coastguard Worker noexcept(noexcept(x.swap(y))); 263*58b9f456SAndroid Build Coastguard Worker 264*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator, class U> 265*58b9f456SAndroid Build Coastguard Worker void erase(vector<T, Allocator>& c, const U& value); // C++20 266*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator, class Predicate> 267*58b9f456SAndroid Build Coastguard Worker void erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 268*58b9f456SAndroid Build Coastguard Worker 269*58b9f456SAndroid Build Coastguard Worker} // std 270*58b9f456SAndroid Build Coastguard Worker 271*58b9f456SAndroid Build Coastguard Worker*/ 272*58b9f456SAndroid Build Coastguard Worker 273*58b9f456SAndroid Build Coastguard Worker#include <__config> 274*58b9f456SAndroid Build Coastguard Worker#include <iosfwd> // for forward declaration of vector 275*58b9f456SAndroid Build Coastguard Worker#include <__bit_reference> 276*58b9f456SAndroid Build Coastguard Worker#include <type_traits> 277*58b9f456SAndroid Build Coastguard Worker#include <climits> 278*58b9f456SAndroid Build Coastguard Worker#include <limits> 279*58b9f456SAndroid Build Coastguard Worker#include <initializer_list> 280*58b9f456SAndroid Build Coastguard Worker#include <memory> 281*58b9f456SAndroid Build Coastguard Worker#include <stdexcept> 282*58b9f456SAndroid Build Coastguard Worker#include <algorithm> 283*58b9f456SAndroid Build Coastguard Worker#include <cstring> 284*58b9f456SAndroid Build Coastguard Worker#include <version> 285*58b9f456SAndroid Build Coastguard Worker#include <__split_buffer> 286*58b9f456SAndroid Build Coastguard Worker#include <__functional_base> 287*58b9f456SAndroid Build Coastguard Worker 288*58b9f456SAndroid Build Coastguard Worker#include <__debug> 289*58b9f456SAndroid Build Coastguard Worker 290*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 291*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header 292*58b9f456SAndroid Build Coastguard Worker#endif 293*58b9f456SAndroid Build Coastguard Worker 294*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS 295*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros> 296*58b9f456SAndroid Build Coastguard Worker 297*58b9f456SAndroid Build Coastguard Worker 298*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD 299*58b9f456SAndroid Build Coastguard Worker 300*58b9f456SAndroid Build Coastguard Workertemplate <bool> 301*58b9f456SAndroid Build Coastguard Workerclass __vector_base_common 302*58b9f456SAndroid Build Coastguard Worker{ 303*58b9f456SAndroid Build Coastguard Workerprotected: 304*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY __vector_base_common() {} 305*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NORETURN void __throw_length_error() const; 306*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NORETURN void __throw_out_of_range() const; 307*58b9f456SAndroid Build Coastguard Worker}; 308*58b9f456SAndroid Build Coastguard Worker 309*58b9f456SAndroid Build Coastguard Workertemplate <bool __b> 310*58b9f456SAndroid Build Coastguard Workervoid 311*58b9f456SAndroid Build Coastguard Worker__vector_base_common<__b>::__throw_length_error() const 312*58b9f456SAndroid Build Coastguard Worker{ 313*58b9f456SAndroid Build Coastguard Worker _VSTD::__throw_length_error("vector"); 314*58b9f456SAndroid Build Coastguard Worker} 315*58b9f456SAndroid Build Coastguard Worker 316*58b9f456SAndroid Build Coastguard Workertemplate <bool __b> 317*58b9f456SAndroid Build Coastguard Workervoid 318*58b9f456SAndroid Build Coastguard Worker__vector_base_common<__b>::__throw_out_of_range() const 319*58b9f456SAndroid Build Coastguard Worker{ 320*58b9f456SAndroid Build Coastguard Worker _VSTD::__throw_out_of_range("vector"); 321*58b9f456SAndroid Build Coastguard Worker} 322*58b9f456SAndroid Build Coastguard Worker 323*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>) 324*58b9f456SAndroid Build Coastguard Worker 325*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 326*58b9f456SAndroid Build Coastguard Workerclass __vector_base 327*58b9f456SAndroid Build Coastguard Worker : protected __vector_base_common<true> 328*58b9f456SAndroid Build Coastguard Worker{ 329*58b9f456SAndroid Build Coastguard Workerpublic: 330*58b9f456SAndroid Build Coastguard Worker typedef _Allocator allocator_type; 331*58b9f456SAndroid Build Coastguard Worker typedef allocator_traits<allocator_type> __alloc_traits; 332*58b9f456SAndroid Build Coastguard Worker typedef typename __alloc_traits::size_type size_type; 333*58b9f456SAndroid Build Coastguard Workerprotected: 334*58b9f456SAndroid Build Coastguard Worker typedef _Tp value_type; 335*58b9f456SAndroid Build Coastguard Worker typedef value_type& reference; 336*58b9f456SAndroid Build Coastguard Worker typedef const value_type& const_reference; 337*58b9f456SAndroid Build Coastguard Worker typedef typename __alloc_traits::difference_type difference_type; 338*58b9f456SAndroid Build Coastguard Worker typedef typename __alloc_traits::pointer pointer; 339*58b9f456SAndroid Build Coastguard Worker typedef typename __alloc_traits::const_pointer const_pointer; 340*58b9f456SAndroid Build Coastguard Worker typedef pointer iterator; 341*58b9f456SAndroid Build Coastguard Worker typedef const_pointer const_iterator; 342*58b9f456SAndroid Build Coastguard Worker 343*58b9f456SAndroid Build Coastguard Worker pointer __begin_; 344*58b9f456SAndroid Build Coastguard Worker pointer __end_; 345*58b9f456SAndroid Build Coastguard Worker __compressed_pair<pointer, allocator_type> __end_cap_; 346*58b9f456SAndroid Build Coastguard Worker 347*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 348*58b9f456SAndroid Build Coastguard Worker allocator_type& __alloc() _NOEXCEPT 349*58b9f456SAndroid Build Coastguard Worker {return __end_cap_.second();} 350*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 351*58b9f456SAndroid Build Coastguard Worker const allocator_type& __alloc() const _NOEXCEPT 352*58b9f456SAndroid Build Coastguard Worker {return __end_cap_.second();} 353*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 354*58b9f456SAndroid Build Coastguard Worker pointer& __end_cap() _NOEXCEPT 355*58b9f456SAndroid Build Coastguard Worker {return __end_cap_.first();} 356*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 357*58b9f456SAndroid Build Coastguard Worker const pointer& __end_cap() const _NOEXCEPT 358*58b9f456SAndroid Build Coastguard Worker {return __end_cap_.first();} 359*58b9f456SAndroid Build Coastguard Worker 360*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 361*58b9f456SAndroid Build Coastguard Worker __vector_base() 362*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); 363*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); 364*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 365*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT; 366*58b9f456SAndroid Build Coastguard Worker#endif 367*58b9f456SAndroid Build Coastguard Worker ~__vector_base(); 368*58b9f456SAndroid Build Coastguard Worker 369*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 370*58b9f456SAndroid Build Coastguard Worker void clear() _NOEXCEPT {__destruct_at_end(__begin_);} 371*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 372*58b9f456SAndroid Build Coastguard Worker size_type capacity() const _NOEXCEPT 373*58b9f456SAndroid Build Coastguard Worker {return static_cast<size_type>(__end_cap() - __begin_);} 374*58b9f456SAndroid Build Coastguard Worker 375*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 376*58b9f456SAndroid Build Coastguard Worker void __destruct_at_end(pointer __new_last) _NOEXCEPT; 377*58b9f456SAndroid Build Coastguard Worker 378*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 379*58b9f456SAndroid Build Coastguard Worker void __copy_assign_alloc(const __vector_base& __c) 380*58b9f456SAndroid Build Coastguard Worker {__copy_assign_alloc(__c, integral_constant<bool, 381*58b9f456SAndroid Build Coastguard Worker __alloc_traits::propagate_on_container_copy_assignment::value>());} 382*58b9f456SAndroid Build Coastguard Worker 383*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 384*58b9f456SAndroid Build Coastguard Worker void __move_assign_alloc(__vector_base& __c) 385*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_( 386*58b9f456SAndroid Build Coastguard Worker !__alloc_traits::propagate_on_container_move_assignment::value || 387*58b9f456SAndroid Build Coastguard Worker is_nothrow_move_assignable<allocator_type>::value) 388*58b9f456SAndroid Build Coastguard Worker {__move_assign_alloc(__c, integral_constant<bool, 389*58b9f456SAndroid Build Coastguard Worker __alloc_traits::propagate_on_container_move_assignment::value>());} 390*58b9f456SAndroid Build Coastguard Workerprivate: 391*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 392*58b9f456SAndroid Build Coastguard Worker void __copy_assign_alloc(const __vector_base& __c, true_type) 393*58b9f456SAndroid Build Coastguard Worker { 394*58b9f456SAndroid Build Coastguard Worker if (__alloc() != __c.__alloc()) 395*58b9f456SAndroid Build Coastguard Worker { 396*58b9f456SAndroid Build Coastguard Worker clear(); 397*58b9f456SAndroid Build Coastguard Worker __alloc_traits::deallocate(__alloc(), __begin_, capacity()); 398*58b9f456SAndroid Build Coastguard Worker __begin_ = __end_ = __end_cap() = nullptr; 399*58b9f456SAndroid Build Coastguard Worker } 400*58b9f456SAndroid Build Coastguard Worker __alloc() = __c.__alloc(); 401*58b9f456SAndroid Build Coastguard Worker } 402*58b9f456SAndroid Build Coastguard Worker 403*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 404*58b9f456SAndroid Build Coastguard Worker void __copy_assign_alloc(const __vector_base&, false_type) 405*58b9f456SAndroid Build Coastguard Worker {} 406*58b9f456SAndroid Build Coastguard Worker 407*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 408*58b9f456SAndroid Build Coastguard Worker void __move_assign_alloc(__vector_base& __c, true_type) 409*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 410*58b9f456SAndroid Build Coastguard Worker { 411*58b9f456SAndroid Build Coastguard Worker __alloc() = _VSTD::move(__c.__alloc()); 412*58b9f456SAndroid Build Coastguard Worker } 413*58b9f456SAndroid Build Coastguard Worker 414*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 415*58b9f456SAndroid Build Coastguard Worker void __move_assign_alloc(__vector_base&, false_type) 416*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 417*58b9f456SAndroid Build Coastguard Worker {} 418*58b9f456SAndroid Build Coastguard Worker}; 419*58b9f456SAndroid Build Coastguard Worker 420*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 421*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 422*58b9f456SAndroid Build Coastguard Workervoid 423*58b9f456SAndroid Build Coastguard Worker__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT 424*58b9f456SAndroid Build Coastguard Worker{ 425*58b9f456SAndroid Build Coastguard Worker pointer __soon_to_be_end = __end_; 426*58b9f456SAndroid Build Coastguard Worker while (__new_last != __soon_to_be_end) 427*58b9f456SAndroid Build Coastguard Worker __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end)); 428*58b9f456SAndroid Build Coastguard Worker __end_ = __new_last; 429*58b9f456SAndroid Build Coastguard Worker} 430*58b9f456SAndroid Build Coastguard Worker 431*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 432*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 433*58b9f456SAndroid Build Coastguard Worker__vector_base<_Tp, _Allocator>::__vector_base() 434*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) 435*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 436*58b9f456SAndroid Build Coastguard Worker __end_(nullptr), 437*58b9f456SAndroid Build Coastguard Worker __end_cap_(nullptr) 438*58b9f456SAndroid Build Coastguard Worker{ 439*58b9f456SAndroid Build Coastguard Worker} 440*58b9f456SAndroid Build Coastguard Worker 441*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 442*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 443*58b9f456SAndroid Build Coastguard Worker__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) 444*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 445*58b9f456SAndroid Build Coastguard Worker __end_(nullptr), 446*58b9f456SAndroid Build Coastguard Worker __end_cap_(nullptr, __a) 447*58b9f456SAndroid Build Coastguard Worker{ 448*58b9f456SAndroid Build Coastguard Worker} 449*58b9f456SAndroid Build Coastguard Worker 450*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 451*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 452*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 453*58b9f456SAndroid Build Coastguard Worker__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT 454*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 455*58b9f456SAndroid Build Coastguard Worker __end_(nullptr), 456*58b9f456SAndroid Build Coastguard Worker __end_cap_(nullptr, std::move(__a)) {} 457*58b9f456SAndroid Build Coastguard Worker#endif 458*58b9f456SAndroid Build Coastguard Worker 459*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 460*58b9f456SAndroid Build Coastguard Worker__vector_base<_Tp, _Allocator>::~__vector_base() 461*58b9f456SAndroid Build Coastguard Worker{ 462*58b9f456SAndroid Build Coastguard Worker if (__begin_ != nullptr) 463*58b9f456SAndroid Build Coastguard Worker { 464*58b9f456SAndroid Build Coastguard Worker clear(); 465*58b9f456SAndroid Build Coastguard Worker __alloc_traits::deallocate(__alloc(), __begin_, capacity()); 466*58b9f456SAndroid Build Coastguard Worker } 467*58b9f456SAndroid Build Coastguard Worker} 468*58b9f456SAndroid Build Coastguard Worker 469*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator /* = allocator<_Tp> */> 470*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS vector 471*58b9f456SAndroid Build Coastguard Worker : private __vector_base<_Tp, _Allocator> 472*58b9f456SAndroid Build Coastguard Worker{ 473*58b9f456SAndroid Build Coastguard Workerprivate: 474*58b9f456SAndroid Build Coastguard Worker typedef __vector_base<_Tp, _Allocator> __base; 475*58b9f456SAndroid Build Coastguard Worker typedef allocator<_Tp> __default_allocator_type; 476*58b9f456SAndroid Build Coastguard Workerpublic: 477*58b9f456SAndroid Build Coastguard Worker typedef vector __self; 478*58b9f456SAndroid Build Coastguard Worker typedef _Tp value_type; 479*58b9f456SAndroid Build Coastguard Worker typedef _Allocator allocator_type; 480*58b9f456SAndroid Build Coastguard Worker typedef typename __base::__alloc_traits __alloc_traits; 481*58b9f456SAndroid Build Coastguard Worker typedef typename __base::reference reference; 482*58b9f456SAndroid Build Coastguard Worker typedef typename __base::const_reference const_reference; 483*58b9f456SAndroid Build Coastguard Worker typedef typename __base::size_type size_type; 484*58b9f456SAndroid Build Coastguard Worker typedef typename __base::difference_type difference_type; 485*58b9f456SAndroid Build Coastguard Worker typedef typename __base::pointer pointer; 486*58b9f456SAndroid Build Coastguard Worker typedef typename __base::const_pointer const_pointer; 487*58b9f456SAndroid Build Coastguard Worker typedef __wrap_iter<pointer> iterator; 488*58b9f456SAndroid Build Coastguard Worker typedef __wrap_iter<const_pointer> const_iterator; 489*58b9f456SAndroid Build Coastguard Worker typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 490*58b9f456SAndroid Build Coastguard Worker typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 491*58b9f456SAndroid Build Coastguard Worker 492*58b9f456SAndroid Build Coastguard Worker static_assert((is_same<typename allocator_type::value_type, value_type>::value), 493*58b9f456SAndroid Build Coastguard Worker "Allocator::value_type must be same type as value_type"); 494*58b9f456SAndroid Build Coastguard Worker 495*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 496*58b9f456SAndroid Build Coastguard Worker vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) 497*58b9f456SAndroid Build Coastguard Worker { 498*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 499*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 500*58b9f456SAndroid Build Coastguard Worker#endif 501*58b9f456SAndroid Build Coastguard Worker } 502*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) 503*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14 504*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) 505*58b9f456SAndroid Build Coastguard Worker#else 506*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 507*58b9f456SAndroid Build Coastguard Worker#endif 508*58b9f456SAndroid Build Coastguard Worker : __base(__a) 509*58b9f456SAndroid Build Coastguard Worker { 510*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 511*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 512*58b9f456SAndroid Build Coastguard Worker#endif 513*58b9f456SAndroid Build Coastguard Worker } 514*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type __n); 515*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 516*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type __n, const allocator_type& __a); 517*58b9f456SAndroid Build Coastguard Worker#endif 518*58b9f456SAndroid Build Coastguard Worker vector(size_type __n, const value_type& __x); 519*58b9f456SAndroid Build Coastguard Worker vector(size_type __n, const value_type& __x, const allocator_type& __a); 520*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 521*58b9f456SAndroid Build Coastguard Worker vector(_InputIterator __first, 522*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 523*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 524*58b9f456SAndroid Build Coastguard Worker is_constructible< 525*58b9f456SAndroid Build Coastguard Worker value_type, 526*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value, 527*58b9f456SAndroid Build Coastguard Worker _InputIterator>::type __last); 528*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 529*58b9f456SAndroid Build Coastguard Worker vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, 530*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 531*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 532*58b9f456SAndroid Build Coastguard Worker is_constructible< 533*58b9f456SAndroid Build Coastguard Worker value_type, 534*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); 535*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 536*58b9f456SAndroid Build Coastguard Worker vector(_ForwardIterator __first, 537*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value && 538*58b9f456SAndroid Build Coastguard Worker is_constructible< 539*58b9f456SAndroid Build Coastguard Worker value_type, 540*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value, 541*58b9f456SAndroid Build Coastguard Worker _ForwardIterator>::type __last); 542*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 543*58b9f456SAndroid Build Coastguard Worker vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, 544*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value && 545*58b9f456SAndroid Build Coastguard Worker is_constructible< 546*58b9f456SAndroid Build Coastguard Worker value_type, 547*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); 548*58b9f456SAndroid Build Coastguard Worker 549*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 550*58b9f456SAndroid Build Coastguard Worker ~vector() 551*58b9f456SAndroid Build Coastguard Worker { 552*58b9f456SAndroid Build Coastguard Worker __annotate_delete(); 553*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 554*58b9f456SAndroid Build Coastguard Worker __get_db()->__erase_c(this); 555*58b9f456SAndroid Build Coastguard Worker#endif 556*58b9f456SAndroid Build Coastguard Worker } 557*58b9f456SAndroid Build Coastguard Worker 558*58b9f456SAndroid Build Coastguard Worker vector(const vector& __x); 559*58b9f456SAndroid Build Coastguard Worker vector(const vector& __x, const allocator_type& __a); 560*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 561*58b9f456SAndroid Build Coastguard Worker vector& operator=(const vector& __x); 562*58b9f456SAndroid Build Coastguard Worker 563*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 564*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 565*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> __il); 566*58b9f456SAndroid Build Coastguard Worker 567*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 568*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> __il, const allocator_type& __a); 569*58b9f456SAndroid Build Coastguard Worker 570*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 571*58b9f456SAndroid Build Coastguard Worker vector(vector&& __x) 572*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 573*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT; 574*58b9f456SAndroid Build Coastguard Worker#else 575*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); 576*58b9f456SAndroid Build Coastguard Worker#endif 577*58b9f456SAndroid Build Coastguard Worker 578*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 579*58b9f456SAndroid Build Coastguard Worker vector(vector&& __x, const allocator_type& __a); 580*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 581*58b9f456SAndroid Build Coastguard Worker vector& operator=(vector&& __x) 582*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); 583*58b9f456SAndroid Build Coastguard Worker 584*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 585*58b9f456SAndroid Build Coastguard Worker vector& operator=(initializer_list<value_type> __il) 586*58b9f456SAndroid Build Coastguard Worker {assign(__il.begin(), __il.end()); return *this;} 587*58b9f456SAndroid Build Coastguard Worker 588*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 589*58b9f456SAndroid Build Coastguard Worker 590*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 591*58b9f456SAndroid Build Coastguard Worker typename enable_if 592*58b9f456SAndroid Build Coastguard Worker < 593*58b9f456SAndroid Build Coastguard Worker __is_input_iterator <_InputIterator>::value && 594*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 595*58b9f456SAndroid Build Coastguard Worker is_constructible< 596*58b9f456SAndroid Build Coastguard Worker value_type, 597*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value, 598*58b9f456SAndroid Build Coastguard Worker void 599*58b9f456SAndroid Build Coastguard Worker >::type 600*58b9f456SAndroid Build Coastguard Worker assign(_InputIterator __first, _InputIterator __last); 601*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 602*58b9f456SAndroid Build Coastguard Worker typename enable_if 603*58b9f456SAndroid Build Coastguard Worker < 604*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value && 605*58b9f456SAndroid Build Coastguard Worker is_constructible< 606*58b9f456SAndroid Build Coastguard Worker value_type, 607*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value, 608*58b9f456SAndroid Build Coastguard Worker void 609*58b9f456SAndroid Build Coastguard Worker >::type 610*58b9f456SAndroid Build Coastguard Worker assign(_ForwardIterator __first, _ForwardIterator __last); 611*58b9f456SAndroid Build Coastguard Worker 612*58b9f456SAndroid Build Coastguard Worker void assign(size_type __n, const_reference __u); 613*58b9f456SAndroid Build Coastguard Worker 614*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 615*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 616*58b9f456SAndroid Build Coastguard Worker void assign(initializer_list<value_type> __il) 617*58b9f456SAndroid Build Coastguard Worker {assign(__il.begin(), __il.end());} 618*58b9f456SAndroid Build Coastguard Worker#endif 619*58b9f456SAndroid Build Coastguard Worker 620*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 621*58b9f456SAndroid Build Coastguard Worker allocator_type get_allocator() const _NOEXCEPT 622*58b9f456SAndroid Build Coastguard Worker {return this->__alloc();} 623*58b9f456SAndroid Build Coastguard Worker 624*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; 625*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; 626*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; 627*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; 628*58b9f456SAndroid Build Coastguard Worker 629*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 630*58b9f456SAndroid Build Coastguard Worker reverse_iterator rbegin() _NOEXCEPT 631*58b9f456SAndroid Build Coastguard Worker {return reverse_iterator(end());} 632*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 633*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rbegin() const _NOEXCEPT 634*58b9f456SAndroid Build Coastguard Worker {return const_reverse_iterator(end());} 635*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 636*58b9f456SAndroid Build Coastguard Worker reverse_iterator rend() _NOEXCEPT 637*58b9f456SAndroid Build Coastguard Worker {return reverse_iterator(begin());} 638*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 639*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rend() const _NOEXCEPT 640*58b9f456SAndroid Build Coastguard Worker {return const_reverse_iterator(begin());} 641*58b9f456SAndroid Build Coastguard Worker 642*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 643*58b9f456SAndroid Build Coastguard Worker const_iterator cbegin() const _NOEXCEPT 644*58b9f456SAndroid Build Coastguard Worker {return begin();} 645*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 646*58b9f456SAndroid Build Coastguard Worker const_iterator cend() const _NOEXCEPT 647*58b9f456SAndroid Build Coastguard Worker {return end();} 648*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 649*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crbegin() const _NOEXCEPT 650*58b9f456SAndroid Build Coastguard Worker {return rbegin();} 651*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 652*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crend() const _NOEXCEPT 653*58b9f456SAndroid Build Coastguard Worker {return rend();} 654*58b9f456SAndroid Build Coastguard Worker 655*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 656*58b9f456SAndroid Build Coastguard Worker size_type size() const _NOEXCEPT 657*58b9f456SAndroid Build Coastguard Worker {return static_cast<size_type>(this->__end_ - this->__begin_);} 658*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 659*58b9f456SAndroid Build Coastguard Worker size_type capacity() const _NOEXCEPT 660*58b9f456SAndroid Build Coastguard Worker {return __base::capacity();} 661*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 662*58b9f456SAndroid Build Coastguard Worker bool empty() const _NOEXCEPT 663*58b9f456SAndroid Build Coastguard Worker {return this->__begin_ == this->__end_;} 664*58b9f456SAndroid Build Coastguard Worker size_type max_size() const _NOEXCEPT; 665*58b9f456SAndroid Build Coastguard Worker void reserve(size_type __n); 666*58b9f456SAndroid Build Coastguard Worker void shrink_to_fit() _NOEXCEPT; 667*58b9f456SAndroid Build Coastguard Worker 668*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n); 669*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const; 670*58b9f456SAndroid Build Coastguard Worker reference at(size_type __n); 671*58b9f456SAndroid Build Coastguard Worker const_reference at(size_type __n) const; 672*58b9f456SAndroid Build Coastguard Worker 673*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference front() 674*58b9f456SAndroid Build Coastguard Worker { 675*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); 676*58b9f456SAndroid Build Coastguard Worker return *this->__begin_; 677*58b9f456SAndroid Build Coastguard Worker } 678*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_reference front() const 679*58b9f456SAndroid Build Coastguard Worker { 680*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); 681*58b9f456SAndroid Build Coastguard Worker return *this->__begin_; 682*58b9f456SAndroid Build Coastguard Worker } 683*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference back() 684*58b9f456SAndroid Build Coastguard Worker { 685*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); 686*58b9f456SAndroid Build Coastguard Worker return *(this->__end_ - 1); 687*58b9f456SAndroid Build Coastguard Worker } 688*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_reference back() const 689*58b9f456SAndroid Build Coastguard Worker { 690*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); 691*58b9f456SAndroid Build Coastguard Worker return *(this->__end_ - 1); 692*58b9f456SAndroid Build Coastguard Worker } 693*58b9f456SAndroid Build Coastguard Worker 694*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 695*58b9f456SAndroid Build Coastguard Worker value_type* data() _NOEXCEPT 696*58b9f456SAndroid Build Coastguard Worker {return _VSTD::__to_raw_pointer(this->__begin_);} 697*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 698*58b9f456SAndroid Build Coastguard Worker const value_type* data() const _NOEXCEPT 699*58b9f456SAndroid Build Coastguard Worker {return _VSTD::__to_raw_pointer(this->__begin_);} 700*58b9f456SAndroid Build Coastguard Worker 701*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_CXX03_LANG 702*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 703*58b9f456SAndroid Build Coastguard Worker void __emplace_back(const value_type& __x) { push_back(__x); } 704*58b9f456SAndroid Build Coastguard Worker#else 705*58b9f456SAndroid Build Coastguard Worker template <class _Arg> 706*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 707*58b9f456SAndroid Build Coastguard Worker void __emplace_back(_Arg&& __arg) { 708*58b9f456SAndroid Build Coastguard Worker emplace_back(_VSTD::forward<_Arg>(__arg)); 709*58b9f456SAndroid Build Coastguard Worker } 710*58b9f456SAndroid Build Coastguard Worker#endif 711*58b9f456SAndroid Build Coastguard Worker 712*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); 713*58b9f456SAndroid Build Coastguard Worker 714*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 715*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); 716*58b9f456SAndroid Build Coastguard Worker 717*58b9f456SAndroid Build Coastguard Worker template <class... _Args> 718*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 719*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 720*58b9f456SAndroid Build Coastguard Worker reference emplace_back(_Args&&... __args); 721*58b9f456SAndroid Build Coastguard Worker#else 722*58b9f456SAndroid Build Coastguard Worker void emplace_back(_Args&&... __args); 723*58b9f456SAndroid Build Coastguard Worker#endif 724*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 725*58b9f456SAndroid Build Coastguard Worker 726*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 727*58b9f456SAndroid Build Coastguard Worker void pop_back(); 728*58b9f456SAndroid Build Coastguard Worker 729*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, const_reference __x); 730*58b9f456SAndroid Build Coastguard Worker 731*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 732*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, value_type&& __x); 733*58b9f456SAndroid Build Coastguard Worker template <class... _Args> 734*58b9f456SAndroid Build Coastguard Worker iterator emplace(const_iterator __position, _Args&&... __args); 735*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 736*58b9f456SAndroid Build Coastguard Worker 737*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, size_type __n, const_reference __x); 738*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 739*58b9f456SAndroid Build Coastguard Worker typename enable_if 740*58b9f456SAndroid Build Coastguard Worker < 741*58b9f456SAndroid Build Coastguard Worker __is_input_iterator <_InputIterator>::value && 742*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 743*58b9f456SAndroid Build Coastguard Worker is_constructible< 744*58b9f456SAndroid Build Coastguard Worker value_type, 745*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value, 746*58b9f456SAndroid Build Coastguard Worker iterator 747*58b9f456SAndroid Build Coastguard Worker >::type 748*58b9f456SAndroid Build Coastguard Worker insert(const_iterator __position, _InputIterator __first, _InputIterator __last); 749*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 750*58b9f456SAndroid Build Coastguard Worker typename enable_if 751*58b9f456SAndroid Build Coastguard Worker < 752*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value && 753*58b9f456SAndroid Build Coastguard Worker is_constructible< 754*58b9f456SAndroid Build Coastguard Worker value_type, 755*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value, 756*58b9f456SAndroid Build Coastguard Worker iterator 757*58b9f456SAndroid Build Coastguard Worker >::type 758*58b9f456SAndroid Build Coastguard Worker insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); 759*58b9f456SAndroid Build Coastguard Worker 760*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 761*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 762*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, initializer_list<value_type> __il) 763*58b9f456SAndroid Build Coastguard Worker {return insert(__position, __il.begin(), __il.end());} 764*58b9f456SAndroid Build Coastguard Worker#endif 765*58b9f456SAndroid Build Coastguard Worker 766*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); 767*58b9f456SAndroid Build Coastguard Worker iterator erase(const_iterator __first, const_iterator __last); 768*58b9f456SAndroid Build Coastguard Worker 769*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 770*58b9f456SAndroid Build Coastguard Worker void clear() _NOEXCEPT 771*58b9f456SAndroid Build Coastguard Worker { 772*58b9f456SAndroid Build Coastguard Worker size_type __old_size = size(); 773*58b9f456SAndroid Build Coastguard Worker __base::clear(); 774*58b9f456SAndroid Build Coastguard Worker __annotate_shrink(__old_size); 775*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 776*58b9f456SAndroid Build Coastguard Worker } 777*58b9f456SAndroid Build Coastguard Worker 778*58b9f456SAndroid Build Coastguard Worker void resize(size_type __sz); 779*58b9f456SAndroid Build Coastguard Worker void resize(size_type __sz, const_reference __x); 780*58b9f456SAndroid Build Coastguard Worker 781*58b9f456SAndroid Build Coastguard Worker void swap(vector&) 782*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14 783*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_DEBUG; 784*58b9f456SAndroid Build Coastguard Worker#else 785*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || 786*58b9f456SAndroid Build Coastguard Worker __is_nothrow_swappable<allocator_type>::value); 787*58b9f456SAndroid Build Coastguard Worker#endif 788*58b9f456SAndroid Build Coastguard Worker 789*58b9f456SAndroid Build Coastguard Worker bool __invariants() const; 790*58b9f456SAndroid Build Coastguard Worker 791*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 792*58b9f456SAndroid Build Coastguard Worker 793*58b9f456SAndroid Build Coastguard Worker bool __dereferenceable(const const_iterator* __i) const; 794*58b9f456SAndroid Build Coastguard Worker bool __decrementable(const const_iterator* __i) const; 795*58b9f456SAndroid Build Coastguard Worker bool __addable(const const_iterator* __i, ptrdiff_t __n) const; 796*58b9f456SAndroid Build Coastguard Worker bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; 797*58b9f456SAndroid Build Coastguard Worker 798*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_DEBUG_LEVEL >= 2 799*58b9f456SAndroid Build Coastguard Worker 800*58b9f456SAndroid Build Coastguard Workerprivate: 801*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); 802*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); 803*58b9f456SAndroid Build Coastguard Worker void __vallocate(size_type __n); 804*58b9f456SAndroid Build Coastguard Worker void __vdeallocate() _NOEXCEPT; 805*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; 806*58b9f456SAndroid Build Coastguard Worker void __construct_at_end(size_type __n); 807*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 808*58b9f456SAndroid Build Coastguard Worker void __construct_at_end(size_type __n, const_reference __x); 809*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 810*58b9f456SAndroid Build Coastguard Worker typename enable_if 811*58b9f456SAndroid Build Coastguard Worker < 812*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 813*58b9f456SAndroid Build Coastguard Worker void 814*58b9f456SAndroid Build Coastguard Worker >::type 815*58b9f456SAndroid Build Coastguard Worker __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); 816*58b9f456SAndroid Build Coastguard Worker void __append(size_type __n); 817*58b9f456SAndroid Build Coastguard Worker void __append(size_type __n, const_reference __x); 818*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 819*58b9f456SAndroid Build Coastguard Worker iterator __make_iter(pointer __p) _NOEXCEPT; 820*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 821*58b9f456SAndroid Build Coastguard Worker const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; 822*58b9f456SAndroid Build Coastguard Worker void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); 823*58b9f456SAndroid Build Coastguard Worker pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); 824*58b9f456SAndroid Build Coastguard Worker void __move_range(pointer __from_s, pointer __from_e, pointer __to); 825*58b9f456SAndroid Build Coastguard Worker void __move_assign(vector& __c, true_type) 826*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); 827*58b9f456SAndroid Build Coastguard Worker void __move_assign(vector& __c, false_type) 828*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(__alloc_traits::is_always_equal::value); 829*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 830*58b9f456SAndroid Build Coastguard Worker void __destruct_at_end(pointer __new_last) _NOEXCEPT 831*58b9f456SAndroid Build Coastguard Worker { 832*58b9f456SAndroid Build Coastguard Worker __invalidate_iterators_past(__new_last); 833*58b9f456SAndroid Build Coastguard Worker size_type __old_size = size(); 834*58b9f456SAndroid Build Coastguard Worker __base::__destruct_at_end(__new_last); 835*58b9f456SAndroid Build Coastguard Worker __annotate_shrink(__old_size); 836*58b9f456SAndroid Build Coastguard Worker } 837*58b9f456SAndroid Build Coastguard Worker 838*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 839*58b9f456SAndroid Build Coastguard Worker template <class _Up> void __push_back_slow_path(_Up&& __x); 840*58b9f456SAndroid Build Coastguard Worker 841*58b9f456SAndroid Build Coastguard Worker template <class... _Args> 842*58b9f456SAndroid Build Coastguard Worker void __emplace_back_slow_path(_Args&&... __args); 843*58b9f456SAndroid Build Coastguard Worker#else 844*58b9f456SAndroid Build Coastguard Worker template <class _Up> void __push_back_slow_path(_Up& __x); 845*58b9f456SAndroid Build Coastguard Worker#endif 846*58b9f456SAndroid Build Coastguard Worker 847*58b9f456SAndroid Build Coastguard Worker // The following functions are no-ops outside of AddressSanitizer mode. 848*58b9f456SAndroid Build Coastguard Worker // We call annotatations only for the default Allocator because other allocators 849*58b9f456SAndroid Build Coastguard Worker // may not meet the AddressSanitizer alignment constraints. 850*58b9f456SAndroid Build Coastguard Worker // See the documentation for __sanitizer_annotate_contiguous_container for more details. 851*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_ASAN 852*58b9f456SAndroid Build Coastguard Worker void __annotate_contiguous_container(const void *__beg, const void *__end, 853*58b9f456SAndroid Build Coastguard Worker const void *__old_mid, 854*58b9f456SAndroid Build Coastguard Worker const void *__new_mid) const 855*58b9f456SAndroid Build Coastguard Worker { 856*58b9f456SAndroid Build Coastguard Worker 857*58b9f456SAndroid Build Coastguard Worker if (__beg && is_same<allocator_type, __default_allocator_type>::value) 858*58b9f456SAndroid Build Coastguard Worker __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); 859*58b9f456SAndroid Build Coastguard Worker } 860*58b9f456SAndroid Build Coastguard Worker#else 861*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 862*58b9f456SAndroid Build Coastguard Worker void __annotate_contiguous_container(const void*, const void*, const void*, 863*58b9f456SAndroid Build Coastguard Worker const void*) const {} 864*58b9f456SAndroid Build Coastguard Worker#endif 865*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 866*58b9f456SAndroid Build Coastguard Worker void __annotate_new(size_type __current_size) const { 867*58b9f456SAndroid Build Coastguard Worker __annotate_contiguous_container(data(), data() + capacity(), 868*58b9f456SAndroid Build Coastguard Worker data() + capacity(), data() + __current_size); 869*58b9f456SAndroid Build Coastguard Worker } 870*58b9f456SAndroid Build Coastguard Worker 871*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 872*58b9f456SAndroid Build Coastguard Worker void __annotate_delete() const { 873*58b9f456SAndroid Build Coastguard Worker __annotate_contiguous_container(data(), data() + capacity(), 874*58b9f456SAndroid Build Coastguard Worker data() + size(), data() + capacity()); 875*58b9f456SAndroid Build Coastguard Worker } 876*58b9f456SAndroid Build Coastguard Worker 877*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 878*58b9f456SAndroid Build Coastguard Worker void __annotate_increase(size_type __n) const 879*58b9f456SAndroid Build Coastguard Worker { 880*58b9f456SAndroid Build Coastguard Worker __annotate_contiguous_container(data(), data() + capacity(), 881*58b9f456SAndroid Build Coastguard Worker data() + size(), data() + size() + __n); 882*58b9f456SAndroid Build Coastguard Worker } 883*58b9f456SAndroid Build Coastguard Worker 884*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 885*58b9f456SAndroid Build Coastguard Worker void __annotate_shrink(size_type __old_size) const 886*58b9f456SAndroid Build Coastguard Worker { 887*58b9f456SAndroid Build Coastguard Worker __annotate_contiguous_container(data(), data() + capacity(), 888*58b9f456SAndroid Build Coastguard Worker data() + __old_size, data() + size()); 889*58b9f456SAndroid Build Coastguard Worker } 890*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_ASAN 891*58b9f456SAndroid Build Coastguard Worker // The annotation for size increase should happen before the actual increase, 892*58b9f456SAndroid Build Coastguard Worker // but if an exception is thrown after that the annotation has to be undone. 893*58b9f456SAndroid Build Coastguard Worker struct __RAII_IncreaseAnnotator { 894*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1) 895*58b9f456SAndroid Build Coastguard Worker : __commit(false), __v(__v), __old_size(__v.size() + __n) { 896*58b9f456SAndroid Build Coastguard Worker __v.__annotate_increase(__n); 897*58b9f456SAndroid Build Coastguard Worker } 898*58b9f456SAndroid Build Coastguard Worker void __done() { __commit = true; } 899*58b9f456SAndroid Build Coastguard Worker ~__RAII_IncreaseAnnotator() { 900*58b9f456SAndroid Build Coastguard Worker if (__commit) return; 901*58b9f456SAndroid Build Coastguard Worker __v.__annotate_shrink(__old_size); 902*58b9f456SAndroid Build Coastguard Worker } 903*58b9f456SAndroid Build Coastguard Worker bool __commit; 904*58b9f456SAndroid Build Coastguard Worker const vector &__v; 905*58b9f456SAndroid Build Coastguard Worker size_type __old_size; 906*58b9f456SAndroid Build Coastguard Worker }; 907*58b9f456SAndroid Build Coastguard Worker#else 908*58b9f456SAndroid Build Coastguard Worker struct __RAII_IncreaseAnnotator { 909*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 910*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator(const vector &, size_type = 1) {} 911*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void __done() {} 912*58b9f456SAndroid Build Coastguard Worker }; 913*58b9f456SAndroid Build Coastguard Worker#endif 914*58b9f456SAndroid Build Coastguard Worker 915*58b9f456SAndroid Build Coastguard Worker}; 916*58b9f456SAndroid Build Coastguard Worker 917*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 918*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator, 919*58b9f456SAndroid Build Coastguard Worker class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>, 920*58b9f456SAndroid Build Coastguard Worker class = typename enable_if<__is_allocator<_Alloc>::value, void>::type 921*58b9f456SAndroid Build Coastguard Worker > 922*58b9f456SAndroid Build Coastguard Workervector(_InputIterator, _InputIterator) 923*58b9f456SAndroid Build Coastguard Worker -> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>; 924*58b9f456SAndroid Build Coastguard Worker 925*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator, 926*58b9f456SAndroid Build Coastguard Worker class _Alloc, 927*58b9f456SAndroid Build Coastguard Worker class = typename enable_if<__is_allocator<_Alloc>::value, void>::type 928*58b9f456SAndroid Build Coastguard Worker > 929*58b9f456SAndroid Build Coastguard Workervector(_InputIterator, _InputIterator, _Alloc) 930*58b9f456SAndroid Build Coastguard Worker -> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>; 931*58b9f456SAndroid Build Coastguard Worker#endif 932*58b9f456SAndroid Build Coastguard Worker 933*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 934*58b9f456SAndroid Build Coastguard Workervoid 935*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) 936*58b9f456SAndroid Build Coastguard Worker{ 937*58b9f456SAndroid Build Coastguard Worker __annotate_delete(); 938*58b9f456SAndroid Build Coastguard Worker __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); 939*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__begin_, __v.__begin_); 940*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__end_, __v.__end_); 941*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__end_cap(), __v.__end_cap()); 942*58b9f456SAndroid Build Coastguard Worker __v.__first_ = __v.__begin_; 943*58b9f456SAndroid Build Coastguard Worker __annotate_new(size()); 944*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 945*58b9f456SAndroid Build Coastguard Worker} 946*58b9f456SAndroid Build Coastguard Worker 947*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 948*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::pointer 949*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) 950*58b9f456SAndroid Build Coastguard Worker{ 951*58b9f456SAndroid Build Coastguard Worker __annotate_delete(); 952*58b9f456SAndroid Build Coastguard Worker pointer __r = __v.__begin_; 953*58b9f456SAndroid Build Coastguard Worker __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_); 954*58b9f456SAndroid Build Coastguard Worker __alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_); 955*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__begin_, __v.__begin_); 956*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__end_, __v.__end_); 957*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__end_cap(), __v.__end_cap()); 958*58b9f456SAndroid Build Coastguard Worker __v.__first_ = __v.__begin_; 959*58b9f456SAndroid Build Coastguard Worker __annotate_new(size()); 960*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 961*58b9f456SAndroid Build Coastguard Worker return __r; 962*58b9f456SAndroid Build Coastguard Worker} 963*58b9f456SAndroid Build Coastguard Worker 964*58b9f456SAndroid Build Coastguard Worker// Allocate space for __n objects 965*58b9f456SAndroid Build Coastguard Worker// throws length_error if __n > max_size() 966*58b9f456SAndroid Build Coastguard Worker// throws (probably bad_alloc) if memory run out 967*58b9f456SAndroid Build Coastguard Worker// Precondition: __begin_ == __end_ == __end_cap() == 0 968*58b9f456SAndroid Build Coastguard Worker// Precondition: __n > 0 969*58b9f456SAndroid Build Coastguard Worker// Postcondition: capacity() == __n 970*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == 0 971*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 972*58b9f456SAndroid Build Coastguard Workervoid 973*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__vallocate(size_type __n) 974*58b9f456SAndroid Build Coastguard Worker{ 975*58b9f456SAndroid Build Coastguard Worker if (__n > max_size()) 976*58b9f456SAndroid Build Coastguard Worker this->__throw_length_error(); 977*58b9f456SAndroid Build Coastguard Worker this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); 978*58b9f456SAndroid Build Coastguard Worker this->__end_cap() = this->__begin_ + __n; 979*58b9f456SAndroid Build Coastguard Worker __annotate_new(0); 980*58b9f456SAndroid Build Coastguard Worker} 981*58b9f456SAndroid Build Coastguard Worker 982*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 983*58b9f456SAndroid Build Coastguard Workervoid 984*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT 985*58b9f456SAndroid Build Coastguard Worker{ 986*58b9f456SAndroid Build Coastguard Worker if (this->__begin_ != nullptr) 987*58b9f456SAndroid Build Coastguard Worker { 988*58b9f456SAndroid Build Coastguard Worker clear(); 989*58b9f456SAndroid Build Coastguard Worker __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity()); 990*58b9f456SAndroid Build Coastguard Worker this->__begin_ = this->__end_ = this->__end_cap() = nullptr; 991*58b9f456SAndroid Build Coastguard Worker } 992*58b9f456SAndroid Build Coastguard Worker} 993*58b9f456SAndroid Build Coastguard Worker 994*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 995*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::size_type 996*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::max_size() const _NOEXCEPT 997*58b9f456SAndroid Build Coastguard Worker{ 998*58b9f456SAndroid Build Coastguard Worker return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), 999*58b9f456SAndroid Build Coastguard Worker numeric_limits<difference_type>::max()); 1000*58b9f456SAndroid Build Coastguard Worker} 1001*58b9f456SAndroid Build Coastguard Worker 1002*58b9f456SAndroid Build Coastguard Worker// Precondition: __new_size > capacity() 1003*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1004*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1005*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::size_type 1006*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__recommend(size_type __new_size) const 1007*58b9f456SAndroid Build Coastguard Worker{ 1008*58b9f456SAndroid Build Coastguard Worker const size_type __ms = max_size(); 1009*58b9f456SAndroid Build Coastguard Worker if (__new_size > __ms) 1010*58b9f456SAndroid Build Coastguard Worker this->__throw_length_error(); 1011*58b9f456SAndroid Build Coastguard Worker const size_type __cap = capacity(); 1012*58b9f456SAndroid Build Coastguard Worker if (__cap >= __ms / 2) 1013*58b9f456SAndroid Build Coastguard Worker return __ms; 1014*58b9f456SAndroid Build Coastguard Worker return _VSTD::max<size_type>(2*__cap, __new_size); 1015*58b9f456SAndroid Build Coastguard Worker} 1016*58b9f456SAndroid Build Coastguard Worker 1017*58b9f456SAndroid Build Coastguard Worker// Default constructs __n objects starting at __end_ 1018*58b9f456SAndroid Build Coastguard Worker// throws if construction throws 1019*58b9f456SAndroid Build Coastguard Worker// Precondition: __n > 0 1020*58b9f456SAndroid Build Coastguard Worker// Precondition: size() + __n <= capacity() 1021*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == size() + __n 1022*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1023*58b9f456SAndroid Build Coastguard Workervoid 1024*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__construct_at_end(size_type __n) 1025*58b9f456SAndroid Build Coastguard Worker{ 1026*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1027*58b9f456SAndroid Build Coastguard Worker do 1028*58b9f456SAndroid Build Coastguard Worker { 1029*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1030*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); 1031*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1032*58b9f456SAndroid Build Coastguard Worker --__n; 1033*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1034*58b9f456SAndroid Build Coastguard Worker } while (__n > 0); 1035*58b9f456SAndroid Build Coastguard Worker} 1036*58b9f456SAndroid Build Coastguard Worker 1037*58b9f456SAndroid Build Coastguard Worker// Copy constructs __n objects starting at __end_ from __x 1038*58b9f456SAndroid Build Coastguard Worker// throws if construction throws 1039*58b9f456SAndroid Build Coastguard Worker// Precondition: __n > 0 1040*58b9f456SAndroid Build Coastguard Worker// Precondition: size() + __n <= capacity() 1041*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == old size() + __n 1042*58b9f456SAndroid Build Coastguard Worker// Postcondition: [i] == __x for all i in [size() - __n, __n) 1043*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1044*58b9f456SAndroid Build Coastguard Workerinline 1045*58b9f456SAndroid Build Coastguard Workervoid 1046*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) 1047*58b9f456SAndroid Build Coastguard Worker{ 1048*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1049*58b9f456SAndroid Build Coastguard Worker do 1050*58b9f456SAndroid Build Coastguard Worker { 1051*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1052*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); 1053*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1054*58b9f456SAndroid Build Coastguard Worker --__n; 1055*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1056*58b9f456SAndroid Build Coastguard Worker } while (__n > 0); 1057*58b9f456SAndroid Build Coastguard Worker} 1058*58b9f456SAndroid Build Coastguard Worker 1059*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1060*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 1061*58b9f456SAndroid Build Coastguard Workertypename enable_if 1062*58b9f456SAndroid Build Coastguard Worker< 1063*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 1064*58b9f456SAndroid Build Coastguard Worker void 1065*58b9f456SAndroid Build Coastguard Worker>::type 1066*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) 1067*58b9f456SAndroid Build Coastguard Worker{ 1068*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1069*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this, __n); 1070*58b9f456SAndroid Build Coastguard Worker __alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_); 1071*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1072*58b9f456SAndroid Build Coastguard Worker} 1073*58b9f456SAndroid Build Coastguard Worker 1074*58b9f456SAndroid Build Coastguard Worker// Default constructs __n objects starting at __end_ 1075*58b9f456SAndroid Build Coastguard Worker// throws if construction throws 1076*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == size() + __n 1077*58b9f456SAndroid Build Coastguard Worker// Exception safety: strong. 1078*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1079*58b9f456SAndroid Build Coastguard Workervoid 1080*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__append(size_type __n) 1081*58b9f456SAndroid Build Coastguard Worker{ 1082*58b9f456SAndroid Build Coastguard Worker if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) 1083*58b9f456SAndroid Build Coastguard Worker this->__construct_at_end(__n); 1084*58b9f456SAndroid Build Coastguard Worker else 1085*58b9f456SAndroid Build Coastguard Worker { 1086*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1087*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a); 1088*58b9f456SAndroid Build Coastguard Worker __v.__construct_at_end(__n); 1089*58b9f456SAndroid Build Coastguard Worker __swap_out_circular_buffer(__v); 1090*58b9f456SAndroid Build Coastguard Worker } 1091*58b9f456SAndroid Build Coastguard Worker} 1092*58b9f456SAndroid Build Coastguard Worker 1093*58b9f456SAndroid Build Coastguard Worker// Default constructs __n objects starting at __end_ 1094*58b9f456SAndroid Build Coastguard Worker// throws if construction throws 1095*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == size() + __n 1096*58b9f456SAndroid Build Coastguard Worker// Exception safety: strong. 1097*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1098*58b9f456SAndroid Build Coastguard Workervoid 1099*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) 1100*58b9f456SAndroid Build Coastguard Worker{ 1101*58b9f456SAndroid Build Coastguard Worker if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) 1102*58b9f456SAndroid Build Coastguard Worker this->__construct_at_end(__n, __x); 1103*58b9f456SAndroid Build Coastguard Worker else 1104*58b9f456SAndroid Build Coastguard Worker { 1105*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1106*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a); 1107*58b9f456SAndroid Build Coastguard Worker __v.__construct_at_end(__n, __x); 1108*58b9f456SAndroid Build Coastguard Worker __swap_out_circular_buffer(__v); 1109*58b9f456SAndroid Build Coastguard Worker } 1110*58b9f456SAndroid Build Coastguard Worker} 1111*58b9f456SAndroid Build Coastguard Worker 1112*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1113*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(size_type __n) 1114*58b9f456SAndroid Build Coastguard Worker{ 1115*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1116*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1117*58b9f456SAndroid Build Coastguard Worker#endif 1118*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1119*58b9f456SAndroid Build Coastguard Worker { 1120*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1121*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n); 1122*58b9f456SAndroid Build Coastguard Worker } 1123*58b9f456SAndroid Build Coastguard Worker} 1124*58b9f456SAndroid Build Coastguard Worker 1125*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 1126*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1127*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) 1128*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1129*58b9f456SAndroid Build Coastguard Worker{ 1130*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1131*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1132*58b9f456SAndroid Build Coastguard Worker#endif 1133*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1134*58b9f456SAndroid Build Coastguard Worker { 1135*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1136*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n); 1137*58b9f456SAndroid Build Coastguard Worker } 1138*58b9f456SAndroid Build Coastguard Worker} 1139*58b9f456SAndroid Build Coastguard Worker#endif 1140*58b9f456SAndroid Build Coastguard Worker 1141*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1142*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) 1143*58b9f456SAndroid Build Coastguard Worker{ 1144*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1145*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1146*58b9f456SAndroid Build Coastguard Worker#endif 1147*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1148*58b9f456SAndroid Build Coastguard Worker { 1149*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1150*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, __x); 1151*58b9f456SAndroid Build Coastguard Worker } 1152*58b9f456SAndroid Build Coastguard Worker} 1153*58b9f456SAndroid Build Coastguard Worker 1154*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1155*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) 1156*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1157*58b9f456SAndroid Build Coastguard Worker{ 1158*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1159*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1160*58b9f456SAndroid Build Coastguard Worker#endif 1161*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1162*58b9f456SAndroid Build Coastguard Worker { 1163*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1164*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, __x); 1165*58b9f456SAndroid Build Coastguard Worker } 1166*58b9f456SAndroid Build Coastguard Worker} 1167*58b9f456SAndroid Build Coastguard Worker 1168*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1169*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 1170*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(_InputIterator __first, 1171*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 1172*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 1173*58b9f456SAndroid Build Coastguard Worker is_constructible< 1174*58b9f456SAndroid Build Coastguard Worker value_type, 1175*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value, 1176*58b9f456SAndroid Build Coastguard Worker _InputIterator>::type __last) 1177*58b9f456SAndroid Build Coastguard Worker{ 1178*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1179*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1180*58b9f456SAndroid Build Coastguard Worker#endif 1181*58b9f456SAndroid Build Coastguard Worker for (; __first != __last; ++__first) 1182*58b9f456SAndroid Build Coastguard Worker __emplace_back(*__first); 1183*58b9f456SAndroid Build Coastguard Worker} 1184*58b9f456SAndroid Build Coastguard Worker 1185*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1186*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 1187*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, 1188*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 1189*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 1190*58b9f456SAndroid Build Coastguard Worker is_constructible< 1191*58b9f456SAndroid Build Coastguard Worker value_type, 1192*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value>::type*) 1193*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1194*58b9f456SAndroid Build Coastguard Worker{ 1195*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1196*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1197*58b9f456SAndroid Build Coastguard Worker#endif 1198*58b9f456SAndroid Build Coastguard Worker for (; __first != __last; ++__first) 1199*58b9f456SAndroid Build Coastguard Worker __emplace_back(*__first); 1200*58b9f456SAndroid Build Coastguard Worker} 1201*58b9f456SAndroid Build Coastguard Worker 1202*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1203*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 1204*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(_ForwardIterator __first, 1205*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value && 1206*58b9f456SAndroid Build Coastguard Worker is_constructible< 1207*58b9f456SAndroid Build Coastguard Worker value_type, 1208*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value, 1209*58b9f456SAndroid Build Coastguard Worker _ForwardIterator>::type __last) 1210*58b9f456SAndroid Build Coastguard Worker{ 1211*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1212*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1213*58b9f456SAndroid Build Coastguard Worker#endif 1214*58b9f456SAndroid Build Coastguard Worker size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 1215*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1216*58b9f456SAndroid Build Coastguard Worker { 1217*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1218*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__first, __last, __n); 1219*58b9f456SAndroid Build Coastguard Worker } 1220*58b9f456SAndroid Build Coastguard Worker} 1221*58b9f456SAndroid Build Coastguard Worker 1222*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1223*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 1224*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, 1225*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value && 1226*58b9f456SAndroid Build Coastguard Worker is_constructible< 1227*58b9f456SAndroid Build Coastguard Worker value_type, 1228*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value>::type*) 1229*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1230*58b9f456SAndroid Build Coastguard Worker{ 1231*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1232*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1233*58b9f456SAndroid Build Coastguard Worker#endif 1234*58b9f456SAndroid Build Coastguard Worker size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 1235*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1236*58b9f456SAndroid Build Coastguard Worker { 1237*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1238*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__first, __last, __n); 1239*58b9f456SAndroid Build Coastguard Worker } 1240*58b9f456SAndroid Build Coastguard Worker} 1241*58b9f456SAndroid Build Coastguard Worker 1242*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1243*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(const vector& __x) 1244*58b9f456SAndroid Build Coastguard Worker : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) 1245*58b9f456SAndroid Build Coastguard Worker{ 1246*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1247*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1248*58b9f456SAndroid Build Coastguard Worker#endif 1249*58b9f456SAndroid Build Coastguard Worker size_type __n = __x.size(); 1250*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1251*58b9f456SAndroid Build Coastguard Worker { 1252*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1253*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__x.__begin_, __x.__end_, __n); 1254*58b9f456SAndroid Build Coastguard Worker } 1255*58b9f456SAndroid Build Coastguard Worker} 1256*58b9f456SAndroid Build Coastguard Worker 1257*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1258*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) 1259*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1260*58b9f456SAndroid Build Coastguard Worker{ 1261*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1262*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1263*58b9f456SAndroid Build Coastguard Worker#endif 1264*58b9f456SAndroid Build Coastguard Worker size_type __n = __x.size(); 1265*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1266*58b9f456SAndroid Build Coastguard Worker { 1267*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 1268*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__x.__begin_, __x.__end_, __n); 1269*58b9f456SAndroid Build Coastguard Worker } 1270*58b9f456SAndroid Build Coastguard Worker} 1271*58b9f456SAndroid Build Coastguard Worker 1272*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1273*58b9f456SAndroid Build Coastguard Worker 1274*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1275*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1276*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(vector&& __x) 1277*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 1278*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 1279*58b9f456SAndroid Build Coastguard Worker#else 1280*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) 1281*58b9f456SAndroid Build Coastguard Worker#endif 1282*58b9f456SAndroid Build Coastguard Worker : __base(_VSTD::move(__x.__alloc())) 1283*58b9f456SAndroid Build Coastguard Worker{ 1284*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1285*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1286*58b9f456SAndroid Build Coastguard Worker __get_db()->swap(this, &__x); 1287*58b9f456SAndroid Build Coastguard Worker#endif 1288*58b9f456SAndroid Build Coastguard Worker this->__begin_ = __x.__begin_; 1289*58b9f456SAndroid Build Coastguard Worker this->__end_ = __x.__end_; 1290*58b9f456SAndroid Build Coastguard Worker this->__end_cap() = __x.__end_cap(); 1291*58b9f456SAndroid Build Coastguard Worker __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; 1292*58b9f456SAndroid Build Coastguard Worker} 1293*58b9f456SAndroid Build Coastguard Worker 1294*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1295*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1296*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) 1297*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1298*58b9f456SAndroid Build Coastguard Worker{ 1299*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1300*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1301*58b9f456SAndroid Build Coastguard Worker#endif 1302*58b9f456SAndroid Build Coastguard Worker if (__a == __x.__alloc()) 1303*58b9f456SAndroid Build Coastguard Worker { 1304*58b9f456SAndroid Build Coastguard Worker this->__begin_ = __x.__begin_; 1305*58b9f456SAndroid Build Coastguard Worker this->__end_ = __x.__end_; 1306*58b9f456SAndroid Build Coastguard Worker this->__end_cap() = __x.__end_cap(); 1307*58b9f456SAndroid Build Coastguard Worker __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; 1308*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1309*58b9f456SAndroid Build Coastguard Worker __get_db()->swap(this, &__x); 1310*58b9f456SAndroid Build Coastguard Worker#endif 1311*58b9f456SAndroid Build Coastguard Worker } 1312*58b9f456SAndroid Build Coastguard Worker else 1313*58b9f456SAndroid Build Coastguard Worker { 1314*58b9f456SAndroid Build Coastguard Worker typedef move_iterator<iterator> _Ip; 1315*58b9f456SAndroid Build Coastguard Worker assign(_Ip(__x.begin()), _Ip(__x.end())); 1316*58b9f456SAndroid Build Coastguard Worker } 1317*58b9f456SAndroid Build Coastguard Worker} 1318*58b9f456SAndroid Build Coastguard Worker 1319*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1320*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1321*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) 1322*58b9f456SAndroid Build Coastguard Worker{ 1323*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1324*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1325*58b9f456SAndroid Build Coastguard Worker#endif 1326*58b9f456SAndroid Build Coastguard Worker if (__il.size() > 0) 1327*58b9f456SAndroid Build Coastguard Worker { 1328*58b9f456SAndroid Build Coastguard Worker __vallocate(__il.size()); 1329*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__il.begin(), __il.end(), __il.size()); 1330*58b9f456SAndroid Build Coastguard Worker } 1331*58b9f456SAndroid Build Coastguard Worker} 1332*58b9f456SAndroid Build Coastguard Worker 1333*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1334*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1335*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) 1336*58b9f456SAndroid Build Coastguard Worker : __base(__a) 1337*58b9f456SAndroid Build Coastguard Worker{ 1338*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1339*58b9f456SAndroid Build Coastguard Worker __get_db()->__insert_c(this); 1340*58b9f456SAndroid Build Coastguard Worker#endif 1341*58b9f456SAndroid Build Coastguard Worker if (__il.size() > 0) 1342*58b9f456SAndroid Build Coastguard Worker { 1343*58b9f456SAndroid Build Coastguard Worker __vallocate(__il.size()); 1344*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__il.begin(), __il.end(), __il.size()); 1345*58b9f456SAndroid Build Coastguard Worker } 1346*58b9f456SAndroid Build Coastguard Worker} 1347*58b9f456SAndroid Build Coastguard Worker 1348*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1349*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1350*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>& 1351*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::operator=(vector&& __x) 1352*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) 1353*58b9f456SAndroid Build Coastguard Worker{ 1354*58b9f456SAndroid Build Coastguard Worker __move_assign(__x, integral_constant<bool, 1355*58b9f456SAndroid Build Coastguard Worker __alloc_traits::propagate_on_container_move_assignment::value>()); 1356*58b9f456SAndroid Build Coastguard Worker return *this; 1357*58b9f456SAndroid Build Coastguard Worker} 1358*58b9f456SAndroid Build Coastguard Worker 1359*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1360*58b9f456SAndroid Build Coastguard Workervoid 1361*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) 1362*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(__alloc_traits::is_always_equal::value) 1363*58b9f456SAndroid Build Coastguard Worker{ 1364*58b9f456SAndroid Build Coastguard Worker if (__base::__alloc() != __c.__alloc()) 1365*58b9f456SAndroid Build Coastguard Worker { 1366*58b9f456SAndroid Build Coastguard Worker typedef move_iterator<iterator> _Ip; 1367*58b9f456SAndroid Build Coastguard Worker assign(_Ip(__c.begin()), _Ip(__c.end())); 1368*58b9f456SAndroid Build Coastguard Worker } 1369*58b9f456SAndroid Build Coastguard Worker else 1370*58b9f456SAndroid Build Coastguard Worker __move_assign(__c, true_type()); 1371*58b9f456SAndroid Build Coastguard Worker} 1372*58b9f456SAndroid Build Coastguard Worker 1373*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1374*58b9f456SAndroid Build Coastguard Workervoid 1375*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) 1376*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 1377*58b9f456SAndroid Build Coastguard Worker{ 1378*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 1379*58b9f456SAndroid Build Coastguard Worker __base::__move_assign_alloc(__c); // this can throw 1380*58b9f456SAndroid Build Coastguard Worker this->__begin_ = __c.__begin_; 1381*58b9f456SAndroid Build Coastguard Worker this->__end_ = __c.__end_; 1382*58b9f456SAndroid Build Coastguard Worker this->__end_cap() = __c.__end_cap(); 1383*58b9f456SAndroid Build Coastguard Worker __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; 1384*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1385*58b9f456SAndroid Build Coastguard Worker __get_db()->swap(this, &__c); 1386*58b9f456SAndroid Build Coastguard Worker#endif 1387*58b9f456SAndroid Build Coastguard Worker} 1388*58b9f456SAndroid Build Coastguard Worker 1389*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 1390*58b9f456SAndroid Build Coastguard Worker 1391*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1392*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1393*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>& 1394*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::operator=(const vector& __x) 1395*58b9f456SAndroid Build Coastguard Worker{ 1396*58b9f456SAndroid Build Coastguard Worker if (this != &__x) 1397*58b9f456SAndroid Build Coastguard Worker { 1398*58b9f456SAndroid Build Coastguard Worker __base::__copy_assign_alloc(__x); 1399*58b9f456SAndroid Build Coastguard Worker assign(__x.__begin_, __x.__end_); 1400*58b9f456SAndroid Build Coastguard Worker } 1401*58b9f456SAndroid Build Coastguard Worker return *this; 1402*58b9f456SAndroid Build Coastguard Worker} 1403*58b9f456SAndroid Build Coastguard Worker 1404*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1405*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 1406*58b9f456SAndroid Build Coastguard Workertypename enable_if 1407*58b9f456SAndroid Build Coastguard Worker< 1408*58b9f456SAndroid Build Coastguard Worker __is_input_iterator <_InputIterator>::value && 1409*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 1410*58b9f456SAndroid Build Coastguard Worker is_constructible< 1411*58b9f456SAndroid Build Coastguard Worker _Tp, 1412*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value, 1413*58b9f456SAndroid Build Coastguard Worker void 1414*58b9f456SAndroid Build Coastguard Worker>::type 1415*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) 1416*58b9f456SAndroid Build Coastguard Worker{ 1417*58b9f456SAndroid Build Coastguard Worker clear(); 1418*58b9f456SAndroid Build Coastguard Worker for (; __first != __last; ++__first) 1419*58b9f456SAndroid Build Coastguard Worker __emplace_back(*__first); 1420*58b9f456SAndroid Build Coastguard Worker} 1421*58b9f456SAndroid Build Coastguard Worker 1422*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1423*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 1424*58b9f456SAndroid Build Coastguard Workertypename enable_if 1425*58b9f456SAndroid Build Coastguard Worker< 1426*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value && 1427*58b9f456SAndroid Build Coastguard Worker is_constructible< 1428*58b9f456SAndroid Build Coastguard Worker _Tp, 1429*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value, 1430*58b9f456SAndroid Build Coastguard Worker void 1431*58b9f456SAndroid Build Coastguard Worker>::type 1432*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) 1433*58b9f456SAndroid Build Coastguard Worker{ 1434*58b9f456SAndroid Build Coastguard Worker size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last)); 1435*58b9f456SAndroid Build Coastguard Worker if (__new_size <= capacity()) 1436*58b9f456SAndroid Build Coastguard Worker { 1437*58b9f456SAndroid Build Coastguard Worker _ForwardIterator __mid = __last; 1438*58b9f456SAndroid Build Coastguard Worker bool __growing = false; 1439*58b9f456SAndroid Build Coastguard Worker if (__new_size > size()) 1440*58b9f456SAndroid Build Coastguard Worker { 1441*58b9f456SAndroid Build Coastguard Worker __growing = true; 1442*58b9f456SAndroid Build Coastguard Worker __mid = __first; 1443*58b9f456SAndroid Build Coastguard Worker _VSTD::advance(__mid, size()); 1444*58b9f456SAndroid Build Coastguard Worker } 1445*58b9f456SAndroid Build Coastguard Worker pointer __m = _VSTD::copy(__first, __mid, this->__begin_); 1446*58b9f456SAndroid Build Coastguard Worker if (__growing) 1447*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__mid, __last, __new_size - size()); 1448*58b9f456SAndroid Build Coastguard Worker else 1449*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(__m); 1450*58b9f456SAndroid Build Coastguard Worker } 1451*58b9f456SAndroid Build Coastguard Worker else 1452*58b9f456SAndroid Build Coastguard Worker { 1453*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 1454*58b9f456SAndroid Build Coastguard Worker __vallocate(__recommend(__new_size)); 1455*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__first, __last, __new_size); 1456*58b9f456SAndroid Build Coastguard Worker } 1457*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 1458*58b9f456SAndroid Build Coastguard Worker} 1459*58b9f456SAndroid Build Coastguard Worker 1460*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1461*58b9f456SAndroid Build Coastguard Workervoid 1462*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) 1463*58b9f456SAndroid Build Coastguard Worker{ 1464*58b9f456SAndroid Build Coastguard Worker if (__n <= capacity()) 1465*58b9f456SAndroid Build Coastguard Worker { 1466*58b9f456SAndroid Build Coastguard Worker size_type __s = size(); 1467*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u); 1468*58b9f456SAndroid Build Coastguard Worker if (__n > __s) 1469*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n - __s, __u); 1470*58b9f456SAndroid Build Coastguard Worker else 1471*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(this->__begin_ + __n); 1472*58b9f456SAndroid Build Coastguard Worker } 1473*58b9f456SAndroid Build Coastguard Worker else 1474*58b9f456SAndroid Build Coastguard Worker { 1475*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 1476*58b9f456SAndroid Build Coastguard Worker __vallocate(__recommend(static_cast<size_type>(__n))); 1477*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, __u); 1478*58b9f456SAndroid Build Coastguard Worker } 1479*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 1480*58b9f456SAndroid Build Coastguard Worker} 1481*58b9f456SAndroid Build Coastguard Worker 1482*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1483*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1484*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1485*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT 1486*58b9f456SAndroid Build Coastguard Worker{ 1487*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1488*58b9f456SAndroid Build Coastguard Worker return iterator(this, __p); 1489*58b9f456SAndroid Build Coastguard Worker#else 1490*58b9f456SAndroid Build Coastguard Worker return iterator(__p); 1491*58b9f456SAndroid Build Coastguard Worker#endif 1492*58b9f456SAndroid Build Coastguard Worker} 1493*58b9f456SAndroid Build Coastguard Worker 1494*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1495*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1496*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::const_iterator 1497*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT 1498*58b9f456SAndroid Build Coastguard Worker{ 1499*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1500*58b9f456SAndroid Build Coastguard Worker return const_iterator(this, __p); 1501*58b9f456SAndroid Build Coastguard Worker#else 1502*58b9f456SAndroid Build Coastguard Worker return const_iterator(__p); 1503*58b9f456SAndroid Build Coastguard Worker#endif 1504*58b9f456SAndroid Build Coastguard Worker} 1505*58b9f456SAndroid Build Coastguard Worker 1506*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1507*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1508*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1509*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::begin() _NOEXCEPT 1510*58b9f456SAndroid Build Coastguard Worker{ 1511*58b9f456SAndroid Build Coastguard Worker return __make_iter(this->__begin_); 1512*58b9f456SAndroid Build Coastguard Worker} 1513*58b9f456SAndroid Build Coastguard Worker 1514*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1515*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1516*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::const_iterator 1517*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::begin() const _NOEXCEPT 1518*58b9f456SAndroid Build Coastguard Worker{ 1519*58b9f456SAndroid Build Coastguard Worker return __make_iter(this->__begin_); 1520*58b9f456SAndroid Build Coastguard Worker} 1521*58b9f456SAndroid Build Coastguard Worker 1522*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1523*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1524*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1525*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::end() _NOEXCEPT 1526*58b9f456SAndroid Build Coastguard Worker{ 1527*58b9f456SAndroid Build Coastguard Worker return __make_iter(this->__end_); 1528*58b9f456SAndroid Build Coastguard Worker} 1529*58b9f456SAndroid Build Coastguard Worker 1530*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1531*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1532*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::const_iterator 1533*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::end() const _NOEXCEPT 1534*58b9f456SAndroid Build Coastguard Worker{ 1535*58b9f456SAndroid Build Coastguard Worker return __make_iter(this->__end_); 1536*58b9f456SAndroid Build Coastguard Worker} 1537*58b9f456SAndroid Build Coastguard Worker 1538*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1539*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1540*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::reference 1541*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::operator[](size_type __n) 1542*58b9f456SAndroid Build Coastguard Worker{ 1543*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); 1544*58b9f456SAndroid Build Coastguard Worker return this->__begin_[__n]; 1545*58b9f456SAndroid Build Coastguard Worker} 1546*58b9f456SAndroid Build Coastguard Worker 1547*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1548*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1549*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::const_reference 1550*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::operator[](size_type __n) const 1551*58b9f456SAndroid Build Coastguard Worker{ 1552*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); 1553*58b9f456SAndroid Build Coastguard Worker return this->__begin_[__n]; 1554*58b9f456SAndroid Build Coastguard Worker} 1555*58b9f456SAndroid Build Coastguard Worker 1556*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1557*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::reference 1558*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::at(size_type __n) 1559*58b9f456SAndroid Build Coastguard Worker{ 1560*58b9f456SAndroid Build Coastguard Worker if (__n >= size()) 1561*58b9f456SAndroid Build Coastguard Worker this->__throw_out_of_range(); 1562*58b9f456SAndroid Build Coastguard Worker return this->__begin_[__n]; 1563*58b9f456SAndroid Build Coastguard Worker} 1564*58b9f456SAndroid Build Coastguard Worker 1565*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1566*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::const_reference 1567*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::at(size_type __n) const 1568*58b9f456SAndroid Build Coastguard Worker{ 1569*58b9f456SAndroid Build Coastguard Worker if (__n >= size()) 1570*58b9f456SAndroid Build Coastguard Worker this->__throw_out_of_range(); 1571*58b9f456SAndroid Build Coastguard Worker return this->__begin_[__n]; 1572*58b9f456SAndroid Build Coastguard Worker} 1573*58b9f456SAndroid Build Coastguard Worker 1574*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1575*58b9f456SAndroid Build Coastguard Workervoid 1576*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::reserve(size_type __n) 1577*58b9f456SAndroid Build Coastguard Worker{ 1578*58b9f456SAndroid Build Coastguard Worker if (__n > capacity()) 1579*58b9f456SAndroid Build Coastguard Worker { 1580*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1581*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); 1582*58b9f456SAndroid Build Coastguard Worker __swap_out_circular_buffer(__v); 1583*58b9f456SAndroid Build Coastguard Worker } 1584*58b9f456SAndroid Build Coastguard Worker} 1585*58b9f456SAndroid Build Coastguard Worker 1586*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1587*58b9f456SAndroid Build Coastguard Workervoid 1588*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT 1589*58b9f456SAndroid Build Coastguard Worker{ 1590*58b9f456SAndroid Build Coastguard Worker if (capacity() > size()) 1591*58b9f456SAndroid Build Coastguard Worker { 1592*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 1593*58b9f456SAndroid Build Coastguard Worker try 1594*58b9f456SAndroid Build Coastguard Worker { 1595*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 1596*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1597*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(size(), size(), __a); 1598*58b9f456SAndroid Build Coastguard Worker __swap_out_circular_buffer(__v); 1599*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 1600*58b9f456SAndroid Build Coastguard Worker } 1601*58b9f456SAndroid Build Coastguard Worker catch (...) 1602*58b9f456SAndroid Build Coastguard Worker { 1603*58b9f456SAndroid Build Coastguard Worker } 1604*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 1605*58b9f456SAndroid Build Coastguard Worker } 1606*58b9f456SAndroid Build Coastguard Worker} 1607*58b9f456SAndroid Build Coastguard Worker 1608*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1609*58b9f456SAndroid Build Coastguard Workertemplate <class _Up> 1610*58b9f456SAndroid Build Coastguard Workervoid 1611*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1612*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) 1613*58b9f456SAndroid Build Coastguard Worker#else 1614*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) 1615*58b9f456SAndroid Build Coastguard Worker#endif 1616*58b9f456SAndroid Build Coastguard Worker{ 1617*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1618*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); 1619*58b9f456SAndroid Build Coastguard Worker // __v.push_back(_VSTD::forward<_Up>(__x)); 1620*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x)); 1621*58b9f456SAndroid Build Coastguard Worker __v.__end_++; 1622*58b9f456SAndroid Build Coastguard Worker __swap_out_circular_buffer(__v); 1623*58b9f456SAndroid Build Coastguard Worker} 1624*58b9f456SAndroid Build Coastguard Worker 1625*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1626*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1627*58b9f456SAndroid Build Coastguard Workervoid 1628*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::push_back(const_reference __x) 1629*58b9f456SAndroid Build Coastguard Worker{ 1630*58b9f456SAndroid Build Coastguard Worker if (this->__end_ != this->__end_cap()) 1631*58b9f456SAndroid Build Coastguard Worker { 1632*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1633*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1634*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), __x); 1635*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1636*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1637*58b9f456SAndroid Build Coastguard Worker } 1638*58b9f456SAndroid Build Coastguard Worker else 1639*58b9f456SAndroid Build Coastguard Worker __push_back_slow_path(__x); 1640*58b9f456SAndroid Build Coastguard Worker} 1641*58b9f456SAndroid Build Coastguard Worker 1642*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1643*58b9f456SAndroid Build Coastguard Worker 1644*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1645*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1646*58b9f456SAndroid Build Coastguard Workervoid 1647*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::push_back(value_type&& __x) 1648*58b9f456SAndroid Build Coastguard Worker{ 1649*58b9f456SAndroid Build Coastguard Worker if (this->__end_ < this->__end_cap()) 1650*58b9f456SAndroid Build Coastguard Worker { 1651*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1652*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1653*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), 1654*58b9f456SAndroid Build Coastguard Worker _VSTD::move(__x)); 1655*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1656*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1657*58b9f456SAndroid Build Coastguard Worker } 1658*58b9f456SAndroid Build Coastguard Worker else 1659*58b9f456SAndroid Build Coastguard Worker __push_back_slow_path(_VSTD::move(__x)); 1660*58b9f456SAndroid Build Coastguard Worker} 1661*58b9f456SAndroid Build Coastguard Worker 1662*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1663*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args> 1664*58b9f456SAndroid Build Coastguard Workervoid 1665*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) 1666*58b9f456SAndroid Build Coastguard Worker{ 1667*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1668*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); 1669*58b9f456SAndroid Build Coastguard Worker// __v.emplace_back(_VSTD::forward<_Args>(__args)...); 1670*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...); 1671*58b9f456SAndroid Build Coastguard Worker __v.__end_++; 1672*58b9f456SAndroid Build Coastguard Worker __swap_out_circular_buffer(__v); 1673*58b9f456SAndroid Build Coastguard Worker} 1674*58b9f456SAndroid Build Coastguard Worker 1675*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1676*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args> 1677*58b9f456SAndroid Build Coastguard Workerinline 1678*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 1679*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::reference 1680*58b9f456SAndroid Build Coastguard Worker#else 1681*58b9f456SAndroid Build Coastguard Workervoid 1682*58b9f456SAndroid Build Coastguard Worker#endif 1683*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::emplace_back(_Args&&... __args) 1684*58b9f456SAndroid Build Coastguard Worker{ 1685*58b9f456SAndroid Build Coastguard Worker if (this->__end_ < this->__end_cap()) 1686*58b9f456SAndroid Build Coastguard Worker { 1687*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1688*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1689*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), 1690*58b9f456SAndroid Build Coastguard Worker _VSTD::forward<_Args>(__args)...); 1691*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1692*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1693*58b9f456SAndroid Build Coastguard Worker } 1694*58b9f456SAndroid Build Coastguard Worker else 1695*58b9f456SAndroid Build Coastguard Worker __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...); 1696*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 1697*58b9f456SAndroid Build Coastguard Worker return this->back(); 1698*58b9f456SAndroid Build Coastguard Worker#endif 1699*58b9f456SAndroid Build Coastguard Worker} 1700*58b9f456SAndroid Build Coastguard Worker 1701*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 1702*58b9f456SAndroid Build Coastguard Worker 1703*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1704*58b9f456SAndroid Build Coastguard Workerinline 1705*58b9f456SAndroid Build Coastguard Workervoid 1706*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::pop_back() 1707*58b9f456SAndroid Build Coastguard Worker{ 1708*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(!empty(), "vector::pop_back called for empty vector"); 1709*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(this->__end_ - 1); 1710*58b9f456SAndroid Build Coastguard Worker} 1711*58b9f456SAndroid Build Coastguard Worker 1712*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1713*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1714*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1715*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::erase(const_iterator __position) 1716*58b9f456SAndroid Build Coastguard Worker{ 1717*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1718*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 1719*58b9f456SAndroid Build Coastguard Worker "vector::erase(iterator) called with an iterator not" 1720*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1721*58b9f456SAndroid Build Coastguard Worker#endif 1722*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__position != end(), 1723*58b9f456SAndroid Build Coastguard Worker "vector::erase(iterator) called with a non-dereferenceable iterator"); 1724*58b9f456SAndroid Build Coastguard Worker difference_type __ps = __position - cbegin(); 1725*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + __ps; 1726*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); 1727*58b9f456SAndroid Build Coastguard Worker this->__invalidate_iterators_past(__p-1); 1728*58b9f456SAndroid Build Coastguard Worker iterator __r = __make_iter(__p); 1729*58b9f456SAndroid Build Coastguard Worker return __r; 1730*58b9f456SAndroid Build Coastguard Worker} 1731*58b9f456SAndroid Build Coastguard Worker 1732*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1733*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1734*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) 1735*58b9f456SAndroid Build Coastguard Worker{ 1736*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1737*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, 1738*58b9f456SAndroid Build Coastguard Worker "vector::erase(iterator, iterator) called with an iterator not" 1739*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1740*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, 1741*58b9f456SAndroid Build Coastguard Worker "vector::erase(iterator, iterator) called with an iterator not" 1742*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1743*58b9f456SAndroid Build Coastguard Worker#endif 1744*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); 1745*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + (__first - begin()); 1746*58b9f456SAndroid Build Coastguard Worker if (__first != __last) { 1747*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); 1748*58b9f456SAndroid Build Coastguard Worker this->__invalidate_iterators_past(__p - 1); 1749*58b9f456SAndroid Build Coastguard Worker } 1750*58b9f456SAndroid Build Coastguard Worker iterator __r = __make_iter(__p); 1751*58b9f456SAndroid Build Coastguard Worker return __r; 1752*58b9f456SAndroid Build Coastguard Worker} 1753*58b9f456SAndroid Build Coastguard Worker 1754*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1755*58b9f456SAndroid Build Coastguard Workervoid 1756*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) 1757*58b9f456SAndroid Build Coastguard Worker{ 1758*58b9f456SAndroid Build Coastguard Worker pointer __old_last = this->__end_; 1759*58b9f456SAndroid Build Coastguard Worker difference_type __n = __old_last - __to; 1760*58b9f456SAndroid Build Coastguard Worker for (pointer __i = __from_s + __n; __i < __from_e; ++__i, ++this->__end_) 1761*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1762*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), 1763*58b9f456SAndroid Build Coastguard Worker _VSTD::move(*__i)); 1764*58b9f456SAndroid Build Coastguard Worker _VSTD::move_backward(__from_s, __from_s + __n, __old_last); 1765*58b9f456SAndroid Build Coastguard Worker} 1766*58b9f456SAndroid Build Coastguard Worker 1767*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1768*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1769*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) 1770*58b9f456SAndroid Build Coastguard Worker{ 1771*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1772*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 1773*58b9f456SAndroid Build Coastguard Worker "vector::insert(iterator, x) called with an iterator not" 1774*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1775*58b9f456SAndroid Build Coastguard Worker#endif 1776*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + (__position - begin()); 1777*58b9f456SAndroid Build Coastguard Worker if (this->__end_ < this->__end_cap()) 1778*58b9f456SAndroid Build Coastguard Worker { 1779*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1780*58b9f456SAndroid Build Coastguard Worker if (__p == this->__end_) 1781*58b9f456SAndroid Build Coastguard Worker { 1782*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1783*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), __x); 1784*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1785*58b9f456SAndroid Build Coastguard Worker } 1786*58b9f456SAndroid Build Coastguard Worker else 1787*58b9f456SAndroid Build Coastguard Worker { 1788*58b9f456SAndroid Build Coastguard Worker __move_range(__p, this->__end_, __p + 1); 1789*58b9f456SAndroid Build Coastguard Worker const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); 1790*58b9f456SAndroid Build Coastguard Worker if (__p <= __xr && __xr < this->__end_) 1791*58b9f456SAndroid Build Coastguard Worker ++__xr; 1792*58b9f456SAndroid Build Coastguard Worker *__p = *__xr; 1793*58b9f456SAndroid Build Coastguard Worker } 1794*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1795*58b9f456SAndroid Build Coastguard Worker } 1796*58b9f456SAndroid Build Coastguard Worker else 1797*58b9f456SAndroid Build Coastguard Worker { 1798*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1799*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); 1800*58b9f456SAndroid Build Coastguard Worker __v.push_back(__x); 1801*58b9f456SAndroid Build Coastguard Worker __p = __swap_out_circular_buffer(__v, __p); 1802*58b9f456SAndroid Build Coastguard Worker } 1803*58b9f456SAndroid Build Coastguard Worker return __make_iter(__p); 1804*58b9f456SAndroid Build Coastguard Worker} 1805*58b9f456SAndroid Build Coastguard Worker 1806*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1807*58b9f456SAndroid Build Coastguard Worker 1808*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1809*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1810*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) 1811*58b9f456SAndroid Build Coastguard Worker{ 1812*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1813*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 1814*58b9f456SAndroid Build Coastguard Worker "vector::insert(iterator, x) called with an iterator not" 1815*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1816*58b9f456SAndroid Build Coastguard Worker#endif 1817*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + (__position - begin()); 1818*58b9f456SAndroid Build Coastguard Worker if (this->__end_ < this->__end_cap()) 1819*58b9f456SAndroid Build Coastguard Worker { 1820*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1821*58b9f456SAndroid Build Coastguard Worker if (__p == this->__end_) 1822*58b9f456SAndroid Build Coastguard Worker { 1823*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1824*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), 1825*58b9f456SAndroid Build Coastguard Worker _VSTD::move(__x)); 1826*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1827*58b9f456SAndroid Build Coastguard Worker } 1828*58b9f456SAndroid Build Coastguard Worker else 1829*58b9f456SAndroid Build Coastguard Worker { 1830*58b9f456SAndroid Build Coastguard Worker __move_range(__p, this->__end_, __p + 1); 1831*58b9f456SAndroid Build Coastguard Worker *__p = _VSTD::move(__x); 1832*58b9f456SAndroid Build Coastguard Worker } 1833*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1834*58b9f456SAndroid Build Coastguard Worker } 1835*58b9f456SAndroid Build Coastguard Worker else 1836*58b9f456SAndroid Build Coastguard Worker { 1837*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1838*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); 1839*58b9f456SAndroid Build Coastguard Worker __v.push_back(_VSTD::move(__x)); 1840*58b9f456SAndroid Build Coastguard Worker __p = __swap_out_circular_buffer(__v, __p); 1841*58b9f456SAndroid Build Coastguard Worker } 1842*58b9f456SAndroid Build Coastguard Worker return __make_iter(__p); 1843*58b9f456SAndroid Build Coastguard Worker} 1844*58b9f456SAndroid Build Coastguard Worker 1845*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1846*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args> 1847*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1848*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) 1849*58b9f456SAndroid Build Coastguard Worker{ 1850*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1851*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 1852*58b9f456SAndroid Build Coastguard Worker "vector::emplace(iterator, x) called with an iterator not" 1853*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1854*58b9f456SAndroid Build Coastguard Worker#endif 1855*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + (__position - begin()); 1856*58b9f456SAndroid Build Coastguard Worker if (this->__end_ < this->__end_cap()) 1857*58b9f456SAndroid Build Coastguard Worker { 1858*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1859*58b9f456SAndroid Build Coastguard Worker if (__p == this->__end_) 1860*58b9f456SAndroid Build Coastguard Worker { 1861*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(this->__alloc(), 1862*58b9f456SAndroid Build Coastguard Worker _VSTD::__to_raw_pointer(this->__end_), 1863*58b9f456SAndroid Build Coastguard Worker _VSTD::forward<_Args>(__args)...); 1864*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1865*58b9f456SAndroid Build Coastguard Worker } 1866*58b9f456SAndroid Build Coastguard Worker else 1867*58b9f456SAndroid Build Coastguard Worker { 1868*58b9f456SAndroid Build Coastguard Worker __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...); 1869*58b9f456SAndroid Build Coastguard Worker __move_range(__p, this->__end_, __p + 1); 1870*58b9f456SAndroid Build Coastguard Worker *__p = _VSTD::move(__tmp.get()); 1871*58b9f456SAndroid Build Coastguard Worker } 1872*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1873*58b9f456SAndroid Build Coastguard Worker } 1874*58b9f456SAndroid Build Coastguard Worker else 1875*58b9f456SAndroid Build Coastguard Worker { 1876*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1877*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); 1878*58b9f456SAndroid Build Coastguard Worker __v.emplace_back(_VSTD::forward<_Args>(__args)...); 1879*58b9f456SAndroid Build Coastguard Worker __p = __swap_out_circular_buffer(__v, __p); 1880*58b9f456SAndroid Build Coastguard Worker } 1881*58b9f456SAndroid Build Coastguard Worker return __make_iter(__p); 1882*58b9f456SAndroid Build Coastguard Worker} 1883*58b9f456SAndroid Build Coastguard Worker 1884*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 1885*58b9f456SAndroid Build Coastguard Worker 1886*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1887*58b9f456SAndroid Build Coastguard Workertypename vector<_Tp, _Allocator>::iterator 1888*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) 1889*58b9f456SAndroid Build Coastguard Worker{ 1890*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1891*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 1892*58b9f456SAndroid Build Coastguard Worker "vector::insert(iterator, n, x) called with an iterator not" 1893*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1894*58b9f456SAndroid Build Coastguard Worker#endif 1895*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + (__position - begin()); 1896*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1897*58b9f456SAndroid Build Coastguard Worker { 1898*58b9f456SAndroid Build Coastguard Worker if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_)) 1899*58b9f456SAndroid Build Coastguard Worker { 1900*58b9f456SAndroid Build Coastguard Worker size_type __old_n = __n; 1901*58b9f456SAndroid Build Coastguard Worker pointer __old_last = this->__end_; 1902*58b9f456SAndroid Build Coastguard Worker if (__n > static_cast<size_type>(this->__end_ - __p)) 1903*58b9f456SAndroid Build Coastguard Worker { 1904*58b9f456SAndroid Build Coastguard Worker size_type __cx = __n - (this->__end_ - __p); 1905*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__cx, __x); 1906*58b9f456SAndroid Build Coastguard Worker __n -= __cx; 1907*58b9f456SAndroid Build Coastguard Worker } 1908*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 1909*58b9f456SAndroid Build Coastguard Worker { 1910*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this, __n); 1911*58b9f456SAndroid Build Coastguard Worker __move_range(__p, __old_last, __p + __old_n); 1912*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1913*58b9f456SAndroid Build Coastguard Worker const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); 1914*58b9f456SAndroid Build Coastguard Worker if (__p <= __xr && __xr < this->__end_) 1915*58b9f456SAndroid Build Coastguard Worker __xr += __old_n; 1916*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(__p, __n, *__xr); 1917*58b9f456SAndroid Build Coastguard Worker } 1918*58b9f456SAndroid Build Coastguard Worker } 1919*58b9f456SAndroid Build Coastguard Worker else 1920*58b9f456SAndroid Build Coastguard Worker { 1921*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1922*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); 1923*58b9f456SAndroid Build Coastguard Worker __v.__construct_at_end(__n, __x); 1924*58b9f456SAndroid Build Coastguard Worker __p = __swap_out_circular_buffer(__v, __p); 1925*58b9f456SAndroid Build Coastguard Worker } 1926*58b9f456SAndroid Build Coastguard Worker } 1927*58b9f456SAndroid Build Coastguard Worker return __make_iter(__p); 1928*58b9f456SAndroid Build Coastguard Worker} 1929*58b9f456SAndroid Build Coastguard Worker 1930*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1931*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 1932*58b9f456SAndroid Build Coastguard Workertypename enable_if 1933*58b9f456SAndroid Build Coastguard Worker< 1934*58b9f456SAndroid Build Coastguard Worker __is_input_iterator <_InputIterator>::value && 1935*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value && 1936*58b9f456SAndroid Build Coastguard Worker is_constructible< 1937*58b9f456SAndroid Build Coastguard Worker _Tp, 1938*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_InputIterator>::reference>::value, 1939*58b9f456SAndroid Build Coastguard Worker typename vector<_Tp, _Allocator>::iterator 1940*58b9f456SAndroid Build Coastguard Worker>::type 1941*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) 1942*58b9f456SAndroid Build Coastguard Worker{ 1943*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 1944*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 1945*58b9f456SAndroid Build Coastguard Worker "vector::insert(iterator, range) called with an iterator not" 1946*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 1947*58b9f456SAndroid Build Coastguard Worker#endif 1948*58b9f456SAndroid Build Coastguard Worker difference_type __off = __position - begin(); 1949*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + __off; 1950*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 1951*58b9f456SAndroid Build Coastguard Worker pointer __old_last = this->__end_; 1952*58b9f456SAndroid Build Coastguard Worker for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) 1953*58b9f456SAndroid Build Coastguard Worker { 1954*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this); 1955*58b9f456SAndroid Build Coastguard Worker __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), 1956*58b9f456SAndroid Build Coastguard Worker *__first); 1957*58b9f456SAndroid Build Coastguard Worker ++this->__end_; 1958*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 1959*58b9f456SAndroid Build Coastguard Worker } 1960*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__a); 1961*58b9f456SAndroid Build Coastguard Worker if (__first != __last) 1962*58b9f456SAndroid Build Coastguard Worker { 1963*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 1964*58b9f456SAndroid Build Coastguard Worker try 1965*58b9f456SAndroid Build Coastguard Worker { 1966*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 1967*58b9f456SAndroid Build Coastguard Worker __v.__construct_at_end(__first, __last); 1968*58b9f456SAndroid Build Coastguard Worker difference_type __old_size = __old_last - this->__begin_; 1969*58b9f456SAndroid Build Coastguard Worker difference_type __old_p = __p - this->__begin_; 1970*58b9f456SAndroid Build Coastguard Worker reserve(__recommend(size() + __v.size())); 1971*58b9f456SAndroid Build Coastguard Worker __p = this->__begin_ + __old_p; 1972*58b9f456SAndroid Build Coastguard Worker __old_last = this->__begin_ + __old_size; 1973*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 1974*58b9f456SAndroid Build Coastguard Worker } 1975*58b9f456SAndroid Build Coastguard Worker catch (...) 1976*58b9f456SAndroid Build Coastguard Worker { 1977*58b9f456SAndroid Build Coastguard Worker erase(__make_iter(__old_last), end()); 1978*58b9f456SAndroid Build Coastguard Worker throw; 1979*58b9f456SAndroid Build Coastguard Worker } 1980*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 1981*58b9f456SAndroid Build Coastguard Worker } 1982*58b9f456SAndroid Build Coastguard Worker __p = _VSTD::rotate(__p, __old_last, this->__end_); 1983*58b9f456SAndroid Build Coastguard Worker insert(__make_iter(__p), make_move_iterator(__v.begin()), 1984*58b9f456SAndroid Build Coastguard Worker make_move_iterator(__v.end())); 1985*58b9f456SAndroid Build Coastguard Worker return begin() + __off; 1986*58b9f456SAndroid Build Coastguard Worker} 1987*58b9f456SAndroid Build Coastguard Worker 1988*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 1989*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 1990*58b9f456SAndroid Build Coastguard Workertypename enable_if 1991*58b9f456SAndroid Build Coastguard Worker< 1992*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value && 1993*58b9f456SAndroid Build Coastguard Worker is_constructible< 1994*58b9f456SAndroid Build Coastguard Worker _Tp, 1995*58b9f456SAndroid Build Coastguard Worker typename iterator_traits<_ForwardIterator>::reference>::value, 1996*58b9f456SAndroid Build Coastguard Worker typename vector<_Tp, _Allocator>::iterator 1997*58b9f456SAndroid Build Coastguard Worker>::type 1998*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) 1999*58b9f456SAndroid Build Coastguard Worker{ 2000*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 2001*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, 2002*58b9f456SAndroid Build Coastguard Worker "vector::insert(iterator, range) called with an iterator not" 2003*58b9f456SAndroid Build Coastguard Worker " referring to this vector"); 2004*58b9f456SAndroid Build Coastguard Worker#endif 2005*58b9f456SAndroid Build Coastguard Worker pointer __p = this->__begin_ + (__position - begin()); 2006*58b9f456SAndroid Build Coastguard Worker difference_type __n = _VSTD::distance(__first, __last); 2007*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2008*58b9f456SAndroid Build Coastguard Worker { 2009*58b9f456SAndroid Build Coastguard Worker if (__n <= this->__end_cap() - this->__end_) 2010*58b9f456SAndroid Build Coastguard Worker { 2011*58b9f456SAndroid Build Coastguard Worker size_type __old_n = __n; 2012*58b9f456SAndroid Build Coastguard Worker pointer __old_last = this->__end_; 2013*58b9f456SAndroid Build Coastguard Worker _ForwardIterator __m = __last; 2014*58b9f456SAndroid Build Coastguard Worker difference_type __dx = this->__end_ - __p; 2015*58b9f456SAndroid Build Coastguard Worker if (__n > __dx) 2016*58b9f456SAndroid Build Coastguard Worker { 2017*58b9f456SAndroid Build Coastguard Worker __m = __first; 2018*58b9f456SAndroid Build Coastguard Worker difference_type __diff = this->__end_ - __p; 2019*58b9f456SAndroid Build Coastguard Worker _VSTD::advance(__m, __diff); 2020*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__m, __last, __n - __diff); 2021*58b9f456SAndroid Build Coastguard Worker __n = __dx; 2022*58b9f456SAndroid Build Coastguard Worker } 2023*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2024*58b9f456SAndroid Build Coastguard Worker { 2025*58b9f456SAndroid Build Coastguard Worker __RAII_IncreaseAnnotator __annotator(*this, __n); 2026*58b9f456SAndroid Build Coastguard Worker __move_range(__p, __old_last, __p + __old_n); 2027*58b9f456SAndroid Build Coastguard Worker __annotator.__done(); 2028*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__first, __m, __p); 2029*58b9f456SAndroid Build Coastguard Worker } 2030*58b9f456SAndroid Build Coastguard Worker } 2031*58b9f456SAndroid Build Coastguard Worker else 2032*58b9f456SAndroid Build Coastguard Worker { 2033*58b9f456SAndroid Build Coastguard Worker allocator_type& __a = this->__alloc(); 2034*58b9f456SAndroid Build Coastguard Worker __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); 2035*58b9f456SAndroid Build Coastguard Worker __v.__construct_at_end(__first, __last); 2036*58b9f456SAndroid Build Coastguard Worker __p = __swap_out_circular_buffer(__v, __p); 2037*58b9f456SAndroid Build Coastguard Worker } 2038*58b9f456SAndroid Build Coastguard Worker } 2039*58b9f456SAndroid Build Coastguard Worker return __make_iter(__p); 2040*58b9f456SAndroid Build Coastguard Worker} 2041*58b9f456SAndroid Build Coastguard Worker 2042*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2043*58b9f456SAndroid Build Coastguard Workervoid 2044*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::resize(size_type __sz) 2045*58b9f456SAndroid Build Coastguard Worker{ 2046*58b9f456SAndroid Build Coastguard Worker size_type __cs = size(); 2047*58b9f456SAndroid Build Coastguard Worker if (__cs < __sz) 2048*58b9f456SAndroid Build Coastguard Worker this->__append(__sz - __cs); 2049*58b9f456SAndroid Build Coastguard Worker else if (__cs > __sz) 2050*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(this->__begin_ + __sz); 2051*58b9f456SAndroid Build Coastguard Worker} 2052*58b9f456SAndroid Build Coastguard Worker 2053*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2054*58b9f456SAndroid Build Coastguard Workervoid 2055*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) 2056*58b9f456SAndroid Build Coastguard Worker{ 2057*58b9f456SAndroid Build Coastguard Worker size_type __cs = size(); 2058*58b9f456SAndroid Build Coastguard Worker if (__cs < __sz) 2059*58b9f456SAndroid Build Coastguard Worker this->__append(__sz - __cs, __x); 2060*58b9f456SAndroid Build Coastguard Worker else if (__cs > __sz) 2061*58b9f456SAndroid Build Coastguard Worker this->__destruct_at_end(this->__begin_ + __sz); 2062*58b9f456SAndroid Build Coastguard Worker} 2063*58b9f456SAndroid Build Coastguard Worker 2064*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2065*58b9f456SAndroid Build Coastguard Workervoid 2066*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::swap(vector& __x) 2067*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14 2068*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_DEBUG 2069*58b9f456SAndroid Build Coastguard Worker#else 2070*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || 2071*58b9f456SAndroid Build Coastguard Worker __is_nothrow_swappable<allocator_type>::value) 2072*58b9f456SAndroid Build Coastguard Worker#endif 2073*58b9f456SAndroid Build Coastguard Worker{ 2074*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || 2075*58b9f456SAndroid Build Coastguard Worker this->__alloc() == __x.__alloc(), 2076*58b9f456SAndroid Build Coastguard Worker "vector::swap: Either propagate_on_container_swap must be true" 2077*58b9f456SAndroid Build Coastguard Worker " or the allocators must compare equal"); 2078*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__begin_, __x.__begin_); 2079*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__end_, __x.__end_); 2080*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__end_cap(), __x.__end_cap()); 2081*58b9f456SAndroid Build Coastguard Worker __swap_allocator(this->__alloc(), __x.__alloc(), 2082*58b9f456SAndroid Build Coastguard Worker integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); 2083*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 2084*58b9f456SAndroid Build Coastguard Worker __get_db()->swap(this, &__x); 2085*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_DEBUG_LEVEL >= 2 2086*58b9f456SAndroid Build Coastguard Worker} 2087*58b9f456SAndroid Build Coastguard Worker 2088*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2089*58b9f456SAndroid Build Coastguard Workerbool 2090*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__invariants() const 2091*58b9f456SAndroid Build Coastguard Worker{ 2092*58b9f456SAndroid Build Coastguard Worker if (this->__begin_ == nullptr) 2093*58b9f456SAndroid Build Coastguard Worker { 2094*58b9f456SAndroid Build Coastguard Worker if (this->__end_ != nullptr || this->__end_cap() != nullptr) 2095*58b9f456SAndroid Build Coastguard Worker return false; 2096*58b9f456SAndroid Build Coastguard Worker } 2097*58b9f456SAndroid Build Coastguard Worker else 2098*58b9f456SAndroid Build Coastguard Worker { 2099*58b9f456SAndroid Build Coastguard Worker if (this->__begin_ > this->__end_) 2100*58b9f456SAndroid Build Coastguard Worker return false; 2101*58b9f456SAndroid Build Coastguard Worker if (this->__begin_ == this->__end_cap()) 2102*58b9f456SAndroid Build Coastguard Worker return false; 2103*58b9f456SAndroid Build Coastguard Worker if (this->__end_ > this->__end_cap()) 2104*58b9f456SAndroid Build Coastguard Worker return false; 2105*58b9f456SAndroid Build Coastguard Worker } 2106*58b9f456SAndroid Build Coastguard Worker return true; 2107*58b9f456SAndroid Build Coastguard Worker} 2108*58b9f456SAndroid Build Coastguard Worker 2109*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 2110*58b9f456SAndroid Build Coastguard Worker 2111*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2112*58b9f456SAndroid Build Coastguard Workerbool 2113*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const 2114*58b9f456SAndroid Build Coastguard Worker{ 2115*58b9f456SAndroid Build Coastguard Worker return this->__begin_ <= __i->base() && __i->base() < this->__end_; 2116*58b9f456SAndroid Build Coastguard Worker} 2117*58b9f456SAndroid Build Coastguard Worker 2118*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2119*58b9f456SAndroid Build Coastguard Workerbool 2120*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const 2121*58b9f456SAndroid Build Coastguard Worker{ 2122*58b9f456SAndroid Build Coastguard Worker return this->__begin_ < __i->base() && __i->base() <= this->__end_; 2123*58b9f456SAndroid Build Coastguard Worker} 2124*58b9f456SAndroid Build Coastguard Worker 2125*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2126*58b9f456SAndroid Build Coastguard Workerbool 2127*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const 2128*58b9f456SAndroid Build Coastguard Worker{ 2129*58b9f456SAndroid Build Coastguard Worker const_pointer __p = __i->base() + __n; 2130*58b9f456SAndroid Build Coastguard Worker return this->__begin_ <= __p && __p <= this->__end_; 2131*58b9f456SAndroid Build Coastguard Worker} 2132*58b9f456SAndroid Build Coastguard Worker 2133*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2134*58b9f456SAndroid Build Coastguard Workerbool 2135*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const 2136*58b9f456SAndroid Build Coastguard Worker{ 2137*58b9f456SAndroid Build Coastguard Worker const_pointer __p = __i->base() + __n; 2138*58b9f456SAndroid Build Coastguard Worker return this->__begin_ <= __p && __p < this->__end_; 2139*58b9f456SAndroid Build Coastguard Worker} 2140*58b9f456SAndroid Build Coastguard Worker 2141*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_DEBUG_LEVEL >= 2 2142*58b9f456SAndroid Build Coastguard Worker 2143*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2144*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2145*58b9f456SAndroid Build Coastguard Workervoid 2146*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__invalidate_all_iterators() 2147*58b9f456SAndroid Build Coastguard Worker{ 2148*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 2149*58b9f456SAndroid Build Coastguard Worker __get_db()->__invalidate_all(this); 2150*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_DEBUG_LEVEL >= 2 2151*58b9f456SAndroid Build Coastguard Worker} 2152*58b9f456SAndroid Build Coastguard Worker 2153*58b9f456SAndroid Build Coastguard Worker 2154*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 2155*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2156*58b9f456SAndroid Build Coastguard Workervoid 2157*58b9f456SAndroid Build Coastguard Workervector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { 2158*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2 2159*58b9f456SAndroid Build Coastguard Worker __c_node* __c = __get_db()->__find_c_and_lock(this); 2160*58b9f456SAndroid Build Coastguard Worker for (__i_node** __p = __c->end_; __p != __c->beg_; ) { 2161*58b9f456SAndroid Build Coastguard Worker --__p; 2162*58b9f456SAndroid Build Coastguard Worker const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); 2163*58b9f456SAndroid Build Coastguard Worker if (__i->base() > __new_last) { 2164*58b9f456SAndroid Build Coastguard Worker (*__p)->__c_ = nullptr; 2165*58b9f456SAndroid Build Coastguard Worker if (--__c->end_ != __p) 2166*58b9f456SAndroid Build Coastguard Worker memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); 2167*58b9f456SAndroid Build Coastguard Worker } 2168*58b9f456SAndroid Build Coastguard Worker } 2169*58b9f456SAndroid Build Coastguard Worker __get_db()->unlock(); 2170*58b9f456SAndroid Build Coastguard Worker#else 2171*58b9f456SAndroid Build Coastguard Worker ((void)__new_last); 2172*58b9f456SAndroid Build Coastguard Worker#endif 2173*58b9f456SAndroid Build Coastguard Worker} 2174*58b9f456SAndroid Build Coastguard Worker 2175*58b9f456SAndroid Build Coastguard Worker// vector<bool> 2176*58b9f456SAndroid Build Coastguard Worker 2177*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> class vector<bool, _Allocator>; 2178*58b9f456SAndroid Build Coastguard Worker 2179*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> struct hash<vector<bool, _Allocator> >; 2180*58b9f456SAndroid Build Coastguard Worker 2181*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2182*58b9f456SAndroid Build Coastguard Workerstruct __has_storage_type<vector<bool, _Allocator> > 2183*58b9f456SAndroid Build Coastguard Worker{ 2184*58b9f456SAndroid Build Coastguard Worker static const bool value = true; 2185*58b9f456SAndroid Build Coastguard Worker}; 2186*58b9f456SAndroid Build Coastguard Worker 2187*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2188*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> 2189*58b9f456SAndroid Build Coastguard Worker : private __vector_base_common<true> 2190*58b9f456SAndroid Build Coastguard Worker{ 2191*58b9f456SAndroid Build Coastguard Workerpublic: 2192*58b9f456SAndroid Build Coastguard Worker typedef vector __self; 2193*58b9f456SAndroid Build Coastguard Worker typedef bool value_type; 2194*58b9f456SAndroid Build Coastguard Worker typedef _Allocator allocator_type; 2195*58b9f456SAndroid Build Coastguard Worker typedef allocator_traits<allocator_type> __alloc_traits; 2196*58b9f456SAndroid Build Coastguard Worker typedef typename __alloc_traits::size_type size_type; 2197*58b9f456SAndroid Build Coastguard Worker typedef typename __alloc_traits::difference_type difference_type; 2198*58b9f456SAndroid Build Coastguard Worker typedef size_type __storage_type; 2199*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<vector, false> pointer; 2200*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<vector, true> const_pointer; 2201*58b9f456SAndroid Build Coastguard Worker typedef pointer iterator; 2202*58b9f456SAndroid Build Coastguard Worker typedef const_pointer const_iterator; 2203*58b9f456SAndroid Build Coastguard Worker typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 2204*58b9f456SAndroid Build Coastguard Worker typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 2205*58b9f456SAndroid Build Coastguard Worker 2206*58b9f456SAndroid Build Coastguard Workerprivate: 2207*58b9f456SAndroid Build Coastguard Worker typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator; 2208*58b9f456SAndroid Build Coastguard Worker typedef allocator_traits<__storage_allocator> __storage_traits; 2209*58b9f456SAndroid Build Coastguard Worker typedef typename __storage_traits::pointer __storage_pointer; 2210*58b9f456SAndroid Build Coastguard Worker typedef typename __storage_traits::const_pointer __const_storage_pointer; 2211*58b9f456SAndroid Build Coastguard Worker 2212*58b9f456SAndroid Build Coastguard Worker __storage_pointer __begin_; 2213*58b9f456SAndroid Build Coastguard Worker size_type __size_; 2214*58b9f456SAndroid Build Coastguard Worker __compressed_pair<size_type, __storage_allocator> __cap_alloc_; 2215*58b9f456SAndroid Build Coastguard Workerpublic: 2216*58b9f456SAndroid Build Coastguard Worker typedef __bit_reference<vector> reference; 2217*58b9f456SAndroid Build Coastguard Worker typedef __bit_const_reference<vector> const_reference; 2218*58b9f456SAndroid Build Coastguard Workerprivate: 2219*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2220*58b9f456SAndroid Build Coastguard Worker size_type& __cap() _NOEXCEPT 2221*58b9f456SAndroid Build Coastguard Worker {return __cap_alloc_.first();} 2222*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2223*58b9f456SAndroid Build Coastguard Worker const size_type& __cap() const _NOEXCEPT 2224*58b9f456SAndroid Build Coastguard Worker {return __cap_alloc_.first();} 2225*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2226*58b9f456SAndroid Build Coastguard Worker __storage_allocator& __alloc() _NOEXCEPT 2227*58b9f456SAndroid Build Coastguard Worker {return __cap_alloc_.second();} 2228*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2229*58b9f456SAndroid Build Coastguard Worker const __storage_allocator& __alloc() const _NOEXCEPT 2230*58b9f456SAndroid Build Coastguard Worker {return __cap_alloc_.second();} 2231*58b9f456SAndroid Build Coastguard Worker 2232*58b9f456SAndroid Build Coastguard Worker static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 2233*58b9f456SAndroid Build Coastguard Worker 2234*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2235*58b9f456SAndroid Build Coastguard Worker static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT 2236*58b9f456SAndroid Build Coastguard Worker {return __n * __bits_per_word;} 2237*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2238*58b9f456SAndroid Build Coastguard Worker static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT 2239*58b9f456SAndroid Build Coastguard Worker {return (__n - 1) / __bits_per_word + 1;} 2240*58b9f456SAndroid Build Coastguard Worker 2241*58b9f456SAndroid Build Coastguard Workerpublic: 2242*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2243*58b9f456SAndroid Build Coastguard Worker vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); 2244*58b9f456SAndroid Build Coastguard Worker 2245*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) 2246*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14 2247*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); 2248*58b9f456SAndroid Build Coastguard Worker#else 2249*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT; 2250*58b9f456SAndroid Build Coastguard Worker#endif 2251*58b9f456SAndroid Build Coastguard Worker ~vector(); 2252*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type __n); 2253*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 2254*58b9f456SAndroid Build Coastguard Worker explicit vector(size_type __n, const allocator_type& __a); 2255*58b9f456SAndroid Build Coastguard Worker#endif 2256*58b9f456SAndroid Build Coastguard Worker vector(size_type __n, const value_type& __v); 2257*58b9f456SAndroid Build Coastguard Worker vector(size_type __n, const value_type& __v, const allocator_type& __a); 2258*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 2259*58b9f456SAndroid Build Coastguard Worker vector(_InputIterator __first, _InputIterator __last, 2260*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 2261*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value>::type* = 0); 2262*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 2263*58b9f456SAndroid Build Coastguard Worker vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, 2264*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 2265*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value>::type* = 0); 2266*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 2267*58b9f456SAndroid Build Coastguard Worker vector(_ForwardIterator __first, _ForwardIterator __last, 2268*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0); 2269*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 2270*58b9f456SAndroid Build Coastguard Worker vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, 2271*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0); 2272*58b9f456SAndroid Build Coastguard Worker 2273*58b9f456SAndroid Build Coastguard Worker vector(const vector& __v); 2274*58b9f456SAndroid Build Coastguard Worker vector(const vector& __v, const allocator_type& __a); 2275*58b9f456SAndroid Build Coastguard Worker vector& operator=(const vector& __v); 2276*58b9f456SAndroid Build Coastguard Worker 2277*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 2278*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> __il); 2279*58b9f456SAndroid Build Coastguard Worker vector(initializer_list<value_type> __il, const allocator_type& __a); 2280*58b9f456SAndroid Build Coastguard Worker 2281*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2282*58b9f456SAndroid Build Coastguard Worker vector(vector&& __v) 2283*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 2284*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT; 2285*58b9f456SAndroid Build Coastguard Worker#else 2286*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); 2287*58b9f456SAndroid Build Coastguard Worker#endif 2288*58b9f456SAndroid Build Coastguard Worker vector(vector&& __v, const allocator_type& __a); 2289*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2290*58b9f456SAndroid Build Coastguard Worker vector& operator=(vector&& __v) 2291*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); 2292*58b9f456SAndroid Build Coastguard Worker 2293*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2294*58b9f456SAndroid Build Coastguard Worker vector& operator=(initializer_list<value_type> __il) 2295*58b9f456SAndroid Build Coastguard Worker {assign(__il.begin(), __il.end()); return *this;} 2296*58b9f456SAndroid Build Coastguard Worker 2297*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 2298*58b9f456SAndroid Build Coastguard Worker 2299*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 2300*58b9f456SAndroid Build Coastguard Worker typename enable_if 2301*58b9f456SAndroid Build Coastguard Worker < 2302*58b9f456SAndroid Build Coastguard Worker __is_input_iterator<_InputIterator>::value && 2303*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value, 2304*58b9f456SAndroid Build Coastguard Worker void 2305*58b9f456SAndroid Build Coastguard Worker >::type 2306*58b9f456SAndroid Build Coastguard Worker assign(_InputIterator __first, _InputIterator __last); 2307*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 2308*58b9f456SAndroid Build Coastguard Worker typename enable_if 2309*58b9f456SAndroid Build Coastguard Worker < 2310*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 2311*58b9f456SAndroid Build Coastguard Worker void 2312*58b9f456SAndroid Build Coastguard Worker >::type 2313*58b9f456SAndroid Build Coastguard Worker assign(_ForwardIterator __first, _ForwardIterator __last); 2314*58b9f456SAndroid Build Coastguard Worker 2315*58b9f456SAndroid Build Coastguard Worker void assign(size_type __n, const value_type& __x); 2316*58b9f456SAndroid Build Coastguard Worker 2317*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 2318*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2319*58b9f456SAndroid Build Coastguard Worker void assign(initializer_list<value_type> __il) 2320*58b9f456SAndroid Build Coastguard Worker {assign(__il.begin(), __il.end());} 2321*58b9f456SAndroid Build Coastguard Worker#endif 2322*58b9f456SAndroid Build Coastguard Worker 2323*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT 2324*58b9f456SAndroid Build Coastguard Worker {return allocator_type(this->__alloc());} 2325*58b9f456SAndroid Build Coastguard Worker 2326*58b9f456SAndroid Build Coastguard Worker size_type max_size() const _NOEXCEPT; 2327*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2328*58b9f456SAndroid Build Coastguard Worker size_type capacity() const _NOEXCEPT 2329*58b9f456SAndroid Build Coastguard Worker {return __internal_cap_to_external(__cap());} 2330*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2331*58b9f456SAndroid Build Coastguard Worker size_type size() const _NOEXCEPT 2332*58b9f456SAndroid Build Coastguard Worker {return __size_;} 2333*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 2334*58b9f456SAndroid Build Coastguard Worker bool empty() const _NOEXCEPT 2335*58b9f456SAndroid Build Coastguard Worker {return __size_ == 0;} 2336*58b9f456SAndroid Build Coastguard Worker void reserve(size_type __n); 2337*58b9f456SAndroid Build Coastguard Worker void shrink_to_fit() _NOEXCEPT; 2338*58b9f456SAndroid Build Coastguard Worker 2339*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2340*58b9f456SAndroid Build Coastguard Worker iterator begin() _NOEXCEPT 2341*58b9f456SAndroid Build Coastguard Worker {return __make_iter(0);} 2342*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2343*58b9f456SAndroid Build Coastguard Worker const_iterator begin() const _NOEXCEPT 2344*58b9f456SAndroid Build Coastguard Worker {return __make_iter(0);} 2345*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2346*58b9f456SAndroid Build Coastguard Worker iterator end() _NOEXCEPT 2347*58b9f456SAndroid Build Coastguard Worker {return __make_iter(__size_);} 2348*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2349*58b9f456SAndroid Build Coastguard Worker const_iterator end() const _NOEXCEPT 2350*58b9f456SAndroid Build Coastguard Worker {return __make_iter(__size_);} 2351*58b9f456SAndroid Build Coastguard Worker 2352*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2353*58b9f456SAndroid Build Coastguard Worker reverse_iterator rbegin() _NOEXCEPT 2354*58b9f456SAndroid Build Coastguard Worker {return reverse_iterator(end());} 2355*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2356*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rbegin() const _NOEXCEPT 2357*58b9f456SAndroid Build Coastguard Worker {return const_reverse_iterator(end());} 2358*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2359*58b9f456SAndroid Build Coastguard Worker reverse_iterator rend() _NOEXCEPT 2360*58b9f456SAndroid Build Coastguard Worker {return reverse_iterator(begin());} 2361*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2362*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rend() const _NOEXCEPT 2363*58b9f456SAndroid Build Coastguard Worker {return const_reverse_iterator(begin());} 2364*58b9f456SAndroid Build Coastguard Worker 2365*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2366*58b9f456SAndroid Build Coastguard Worker const_iterator cbegin() const _NOEXCEPT 2367*58b9f456SAndroid Build Coastguard Worker {return __make_iter(0);} 2368*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2369*58b9f456SAndroid Build Coastguard Worker const_iterator cend() const _NOEXCEPT 2370*58b9f456SAndroid Build Coastguard Worker {return __make_iter(__size_);} 2371*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2372*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crbegin() const _NOEXCEPT 2373*58b9f456SAndroid Build Coastguard Worker {return rbegin();} 2374*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2375*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crend() const _NOEXCEPT 2376*58b9f456SAndroid Build Coastguard Worker {return rend();} 2377*58b9f456SAndroid Build Coastguard Worker 2378*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);} 2379*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);} 2380*58b9f456SAndroid Build Coastguard Worker reference at(size_type __n); 2381*58b9f456SAndroid Build Coastguard Worker const_reference at(size_type __n) const; 2382*58b9f456SAndroid Build Coastguard Worker 2383*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);} 2384*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);} 2385*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);} 2386*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} 2387*58b9f456SAndroid Build Coastguard Worker 2388*58b9f456SAndroid Build Coastguard Worker void push_back(const value_type& __x); 2389*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 2390*58b9f456SAndroid Build Coastguard Worker template <class... _Args> 2391*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 2392*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) 2393*58b9f456SAndroid Build Coastguard Worker#else 2394*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) 2395*58b9f456SAndroid Build Coastguard Worker#endif 2396*58b9f456SAndroid Build Coastguard Worker { 2397*58b9f456SAndroid Build Coastguard Worker push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); 2398*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 2399*58b9f456SAndroid Build Coastguard Worker return this->back(); 2400*58b9f456SAndroid Build Coastguard Worker#endif 2401*58b9f456SAndroid Build Coastguard Worker } 2402*58b9f456SAndroid Build Coastguard Worker#endif 2403*58b9f456SAndroid Build Coastguard Worker 2404*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} 2405*58b9f456SAndroid Build Coastguard Worker 2406*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 2407*58b9f456SAndroid Build Coastguard Worker template <class... _Args> 2408*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) 2409*58b9f456SAndroid Build Coastguard Worker { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } 2410*58b9f456SAndroid Build Coastguard Worker#endif 2411*58b9f456SAndroid Build Coastguard Worker 2412*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, const value_type& __x); 2413*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, size_type __n, const value_type& __x); 2414*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, size_type __n, const_reference __x); 2415*58b9f456SAndroid Build Coastguard Worker template <class _InputIterator> 2416*58b9f456SAndroid Build Coastguard Worker typename enable_if 2417*58b9f456SAndroid Build Coastguard Worker < 2418*58b9f456SAndroid Build Coastguard Worker __is_input_iterator <_InputIterator>::value && 2419*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value, 2420*58b9f456SAndroid Build Coastguard Worker iterator 2421*58b9f456SAndroid Build Coastguard Worker >::type 2422*58b9f456SAndroid Build Coastguard Worker insert(const_iterator __position, _InputIterator __first, _InputIterator __last); 2423*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 2424*58b9f456SAndroid Build Coastguard Worker typename enable_if 2425*58b9f456SAndroid Build Coastguard Worker < 2426*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 2427*58b9f456SAndroid Build Coastguard Worker iterator 2428*58b9f456SAndroid Build Coastguard Worker >::type 2429*58b9f456SAndroid Build Coastguard Worker insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); 2430*58b9f456SAndroid Build Coastguard Worker 2431*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 2432*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2433*58b9f456SAndroid Build Coastguard Worker iterator insert(const_iterator __position, initializer_list<value_type> __il) 2434*58b9f456SAndroid Build Coastguard Worker {return insert(__position, __il.begin(), __il.end());} 2435*58b9f456SAndroid Build Coastguard Worker#endif 2436*58b9f456SAndroid Build Coastguard Worker 2437*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); 2438*58b9f456SAndroid Build Coastguard Worker iterator erase(const_iterator __first, const_iterator __last); 2439*58b9f456SAndroid Build Coastguard Worker 2440*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2441*58b9f456SAndroid Build Coastguard Worker void clear() _NOEXCEPT {__size_ = 0;} 2442*58b9f456SAndroid Build Coastguard Worker 2443*58b9f456SAndroid Build Coastguard Worker void swap(vector&) 2444*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14 2445*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT; 2446*58b9f456SAndroid Build Coastguard Worker#else 2447*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 2448*58b9f456SAndroid Build Coastguard Worker __is_nothrow_swappable<allocator_type>::value); 2449*58b9f456SAndroid Build Coastguard Worker#endif 2450*58b9f456SAndroid Build Coastguard Worker static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } 2451*58b9f456SAndroid Build Coastguard Worker 2452*58b9f456SAndroid Build Coastguard Worker void resize(size_type __sz, value_type __x = false); 2453*58b9f456SAndroid Build Coastguard Worker void flip() _NOEXCEPT; 2454*58b9f456SAndroid Build Coastguard Worker 2455*58b9f456SAndroid Build Coastguard Worker bool __invariants() const; 2456*58b9f456SAndroid Build Coastguard Worker 2457*58b9f456SAndroid Build Coastguard Workerprivate: 2458*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); 2459*58b9f456SAndroid Build Coastguard Worker void __vallocate(size_type __n); 2460*58b9f456SAndroid Build Coastguard Worker void __vdeallocate() _NOEXCEPT; 2461*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2462*58b9f456SAndroid Build Coastguard Worker static size_type __align_it(size_type __new_size) _NOEXCEPT 2463*58b9f456SAndroid Build Coastguard Worker {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);} 2464*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; 2465*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); 2466*58b9f456SAndroid Build Coastguard Worker template <class _ForwardIterator> 2467*58b9f456SAndroid Build Coastguard Worker typename enable_if 2468*58b9f456SAndroid Build Coastguard Worker < 2469*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 2470*58b9f456SAndroid Build Coastguard Worker void 2471*58b9f456SAndroid Build Coastguard Worker >::type 2472*58b9f456SAndroid Build Coastguard Worker __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); 2473*58b9f456SAndroid Build Coastguard Worker void __append(size_type __n, const_reference __x); 2474*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2475*58b9f456SAndroid Build Coastguard Worker reference __make_ref(size_type __pos) _NOEXCEPT 2476*58b9f456SAndroid Build Coastguard Worker {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 2477*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2478*58b9f456SAndroid Build Coastguard Worker const_reference __make_ref(size_type __pos) const _NOEXCEPT 2479*58b9f456SAndroid Build Coastguard Worker {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 2480*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2481*58b9f456SAndroid Build Coastguard Worker iterator __make_iter(size_type __pos) _NOEXCEPT 2482*58b9f456SAndroid Build Coastguard Worker {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} 2483*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2484*58b9f456SAndroid Build Coastguard Worker const_iterator __make_iter(size_type __pos) const _NOEXCEPT 2485*58b9f456SAndroid Build Coastguard Worker {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} 2486*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2487*58b9f456SAndroid Build Coastguard Worker iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT 2488*58b9f456SAndroid Build Coastguard Worker {return begin() + (__p - cbegin());} 2489*58b9f456SAndroid Build Coastguard Worker 2490*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2491*58b9f456SAndroid Build Coastguard Worker void __copy_assign_alloc(const vector& __v) 2492*58b9f456SAndroid Build Coastguard Worker {__copy_assign_alloc(__v, integral_constant<bool, 2493*58b9f456SAndroid Build Coastguard Worker __storage_traits::propagate_on_container_copy_assignment::value>());} 2494*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2495*58b9f456SAndroid Build Coastguard Worker void __copy_assign_alloc(const vector& __c, true_type) 2496*58b9f456SAndroid Build Coastguard Worker { 2497*58b9f456SAndroid Build Coastguard Worker if (__alloc() != __c.__alloc()) 2498*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 2499*58b9f456SAndroid Build Coastguard Worker __alloc() = __c.__alloc(); 2500*58b9f456SAndroid Build Coastguard Worker } 2501*58b9f456SAndroid Build Coastguard Worker 2502*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2503*58b9f456SAndroid Build Coastguard Worker void __copy_assign_alloc(const vector&, false_type) 2504*58b9f456SAndroid Build Coastguard Worker {} 2505*58b9f456SAndroid Build Coastguard Worker 2506*58b9f456SAndroid Build Coastguard Worker void __move_assign(vector& __c, false_type); 2507*58b9f456SAndroid Build Coastguard Worker void __move_assign(vector& __c, true_type) 2508*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); 2509*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2510*58b9f456SAndroid Build Coastguard Worker void __move_assign_alloc(vector& __c) 2511*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_( 2512*58b9f456SAndroid Build Coastguard Worker !__storage_traits::propagate_on_container_move_assignment::value || 2513*58b9f456SAndroid Build Coastguard Worker is_nothrow_move_assignable<allocator_type>::value) 2514*58b9f456SAndroid Build Coastguard Worker {__move_assign_alloc(__c, integral_constant<bool, 2515*58b9f456SAndroid Build Coastguard Worker __storage_traits::propagate_on_container_move_assignment::value>());} 2516*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2517*58b9f456SAndroid Build Coastguard Worker void __move_assign_alloc(vector& __c, true_type) 2518*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 2519*58b9f456SAndroid Build Coastguard Worker { 2520*58b9f456SAndroid Build Coastguard Worker __alloc() = _VSTD::move(__c.__alloc()); 2521*58b9f456SAndroid Build Coastguard Worker } 2522*58b9f456SAndroid Build Coastguard Worker 2523*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 2524*58b9f456SAndroid Build Coastguard Worker void __move_assign_alloc(vector&, false_type) 2525*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 2526*58b9f456SAndroid Build Coastguard Worker {} 2527*58b9f456SAndroid Build Coastguard Worker 2528*58b9f456SAndroid Build Coastguard Worker size_t __hash_code() const _NOEXCEPT; 2529*58b9f456SAndroid Build Coastguard Worker 2530*58b9f456SAndroid Build Coastguard Worker friend class __bit_reference<vector>; 2531*58b9f456SAndroid Build Coastguard Worker friend class __bit_const_reference<vector>; 2532*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<vector, false>; 2533*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<vector, true>; 2534*58b9f456SAndroid Build Coastguard Worker friend struct __bit_array<vector>; 2535*58b9f456SAndroid Build Coastguard Worker friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; 2536*58b9f456SAndroid Build Coastguard Worker}; 2537*58b9f456SAndroid Build Coastguard Worker 2538*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2539*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2540*58b9f456SAndroid Build Coastguard Workervoid 2541*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__invalidate_all_iterators() 2542*58b9f456SAndroid Build Coastguard Worker{ 2543*58b9f456SAndroid Build Coastguard Worker} 2544*58b9f456SAndroid Build Coastguard Worker 2545*58b9f456SAndroid Build Coastguard Worker// Allocate space for __n objects 2546*58b9f456SAndroid Build Coastguard Worker// throws length_error if __n > max_size() 2547*58b9f456SAndroid Build Coastguard Worker// throws (probably bad_alloc) if memory run out 2548*58b9f456SAndroid Build Coastguard Worker// Precondition: __begin_ == __end_ == __cap() == 0 2549*58b9f456SAndroid Build Coastguard Worker// Precondition: __n > 0 2550*58b9f456SAndroid Build Coastguard Worker// Postcondition: capacity() == __n 2551*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == 0 2552*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2553*58b9f456SAndroid Build Coastguard Workervoid 2554*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__vallocate(size_type __n) 2555*58b9f456SAndroid Build Coastguard Worker{ 2556*58b9f456SAndroid Build Coastguard Worker if (__n > max_size()) 2557*58b9f456SAndroid Build Coastguard Worker this->__throw_length_error(); 2558*58b9f456SAndroid Build Coastguard Worker __n = __external_cap_to_internal(__n); 2559*58b9f456SAndroid Build Coastguard Worker this->__begin_ = __storage_traits::allocate(this->__alloc(), __n); 2560*58b9f456SAndroid Build Coastguard Worker this->__size_ = 0; 2561*58b9f456SAndroid Build Coastguard Worker this->__cap() = __n; 2562*58b9f456SAndroid Build Coastguard Worker} 2563*58b9f456SAndroid Build Coastguard Worker 2564*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2565*58b9f456SAndroid Build Coastguard Workervoid 2566*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__vdeallocate() _NOEXCEPT 2567*58b9f456SAndroid Build Coastguard Worker{ 2568*58b9f456SAndroid Build Coastguard Worker if (this->__begin_ != nullptr) 2569*58b9f456SAndroid Build Coastguard Worker { 2570*58b9f456SAndroid Build Coastguard Worker __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); 2571*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 2572*58b9f456SAndroid Build Coastguard Worker this->__begin_ = nullptr; 2573*58b9f456SAndroid Build Coastguard Worker this->__size_ = this->__cap() = 0; 2574*58b9f456SAndroid Build Coastguard Worker } 2575*58b9f456SAndroid Build Coastguard Worker} 2576*58b9f456SAndroid Build Coastguard Worker 2577*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2578*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::size_type 2579*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::max_size() const _NOEXCEPT 2580*58b9f456SAndroid Build Coastguard Worker{ 2581*58b9f456SAndroid Build Coastguard Worker size_type __amax = __storage_traits::max_size(__alloc()); 2582*58b9f456SAndroid Build Coastguard Worker size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always 2583*58b9f456SAndroid Build Coastguard Worker if (__nmax / __bits_per_word <= __amax) 2584*58b9f456SAndroid Build Coastguard Worker return __nmax; 2585*58b9f456SAndroid Build Coastguard Worker return __internal_cap_to_external(__amax); 2586*58b9f456SAndroid Build Coastguard Worker} 2587*58b9f456SAndroid Build Coastguard Worker 2588*58b9f456SAndroid Build Coastguard Worker// Precondition: __new_size > capacity() 2589*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2590*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2591*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::size_type 2592*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__recommend(size_type __new_size) const 2593*58b9f456SAndroid Build Coastguard Worker{ 2594*58b9f456SAndroid Build Coastguard Worker const size_type __ms = max_size(); 2595*58b9f456SAndroid Build Coastguard Worker if (__new_size > __ms) 2596*58b9f456SAndroid Build Coastguard Worker this->__throw_length_error(); 2597*58b9f456SAndroid Build Coastguard Worker const size_type __cap = capacity(); 2598*58b9f456SAndroid Build Coastguard Worker if (__cap >= __ms / 2) 2599*58b9f456SAndroid Build Coastguard Worker return __ms; 2600*58b9f456SAndroid Build Coastguard Worker return _VSTD::max(2*__cap, __align_it(__new_size)); 2601*58b9f456SAndroid Build Coastguard Worker} 2602*58b9f456SAndroid Build Coastguard Worker 2603*58b9f456SAndroid Build Coastguard Worker// Default constructs __n objects starting at __end_ 2604*58b9f456SAndroid Build Coastguard Worker// Precondition: __n > 0 2605*58b9f456SAndroid Build Coastguard Worker// Precondition: size() + __n <= capacity() 2606*58b9f456SAndroid Build Coastguard Worker// Postcondition: size() == size() + __n 2607*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2608*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2609*58b9f456SAndroid Build Coastguard Workervoid 2610*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) 2611*58b9f456SAndroid Build Coastguard Worker{ 2612*58b9f456SAndroid Build Coastguard Worker size_type __old_size = this->__size_; 2613*58b9f456SAndroid Build Coastguard Worker this->__size_ += __n; 2614*58b9f456SAndroid Build Coastguard Worker if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) 2615*58b9f456SAndroid Build Coastguard Worker { 2616*58b9f456SAndroid Build Coastguard Worker if (this->__size_ <= __bits_per_word) 2617*58b9f456SAndroid Build Coastguard Worker this->__begin_[0] = __storage_type(0); 2618*58b9f456SAndroid Build Coastguard Worker else 2619*58b9f456SAndroid Build Coastguard Worker this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); 2620*58b9f456SAndroid Build Coastguard Worker } 2621*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(__make_iter(__old_size), __n, __x); 2622*58b9f456SAndroid Build Coastguard Worker} 2623*58b9f456SAndroid Build Coastguard Worker 2624*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2625*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 2626*58b9f456SAndroid Build Coastguard Workertypename enable_if 2627*58b9f456SAndroid Build Coastguard Worker< 2628*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 2629*58b9f456SAndroid Build Coastguard Worker void 2630*58b9f456SAndroid Build Coastguard Worker>::type 2631*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) 2632*58b9f456SAndroid Build Coastguard Worker{ 2633*58b9f456SAndroid Build Coastguard Worker size_type __old_size = this->__size_; 2634*58b9f456SAndroid Build Coastguard Worker this->__size_ += _VSTD::distance(__first, __last); 2635*58b9f456SAndroid Build Coastguard Worker if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) 2636*58b9f456SAndroid Build Coastguard Worker { 2637*58b9f456SAndroid Build Coastguard Worker if (this->__size_ <= __bits_per_word) 2638*58b9f456SAndroid Build Coastguard Worker this->__begin_[0] = __storage_type(0); 2639*58b9f456SAndroid Build Coastguard Worker else 2640*58b9f456SAndroid Build Coastguard Worker this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); 2641*58b9f456SAndroid Build Coastguard Worker } 2642*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__first, __last, __make_iter(__old_size)); 2643*58b9f456SAndroid Build Coastguard Worker} 2644*58b9f456SAndroid Build Coastguard Worker 2645*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2646*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2647*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector() 2648*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) 2649*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2650*58b9f456SAndroid Build Coastguard Worker __size_(0), 2651*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0) 2652*58b9f456SAndroid Build Coastguard Worker{ 2653*58b9f456SAndroid Build Coastguard Worker} 2654*58b9f456SAndroid Build Coastguard Worker 2655*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2656*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2657*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(const allocator_type& __a) 2658*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14 2659*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) 2660*58b9f456SAndroid Build Coastguard Worker#else 2661*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 2662*58b9f456SAndroid Build Coastguard Worker#endif 2663*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2664*58b9f456SAndroid Build Coastguard Worker __size_(0), 2665*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, static_cast<__storage_allocator>(__a)) 2666*58b9f456SAndroid Build Coastguard Worker{ 2667*58b9f456SAndroid Build Coastguard Worker} 2668*58b9f456SAndroid Build Coastguard Worker 2669*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2670*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(size_type __n) 2671*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2672*58b9f456SAndroid Build Coastguard Worker __size_(0), 2673*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0) 2674*58b9f456SAndroid Build Coastguard Worker{ 2675*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2676*58b9f456SAndroid Build Coastguard Worker { 2677*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2678*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, false); 2679*58b9f456SAndroid Build Coastguard Worker } 2680*58b9f456SAndroid Build Coastguard Worker} 2681*58b9f456SAndroid Build Coastguard Worker 2682*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 2683*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2684*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) 2685*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2686*58b9f456SAndroid Build Coastguard Worker __size_(0), 2687*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, static_cast<__storage_allocator>(__a)) 2688*58b9f456SAndroid Build Coastguard Worker{ 2689*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2690*58b9f456SAndroid Build Coastguard Worker { 2691*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2692*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, false); 2693*58b9f456SAndroid Build Coastguard Worker } 2694*58b9f456SAndroid Build Coastguard Worker} 2695*58b9f456SAndroid Build Coastguard Worker#endif 2696*58b9f456SAndroid Build Coastguard Worker 2697*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2698*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(size_type __n, const value_type& __x) 2699*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2700*58b9f456SAndroid Build Coastguard Worker __size_(0), 2701*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0) 2702*58b9f456SAndroid Build Coastguard Worker{ 2703*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2704*58b9f456SAndroid Build Coastguard Worker { 2705*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2706*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, __x); 2707*58b9f456SAndroid Build Coastguard Worker } 2708*58b9f456SAndroid Build Coastguard Worker} 2709*58b9f456SAndroid Build Coastguard Worker 2710*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2711*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) 2712*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2713*58b9f456SAndroid Build Coastguard Worker __size_(0), 2714*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, static_cast<__storage_allocator>(__a)) 2715*58b9f456SAndroid Build Coastguard Worker{ 2716*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2717*58b9f456SAndroid Build Coastguard Worker { 2718*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2719*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__n, __x); 2720*58b9f456SAndroid Build Coastguard Worker } 2721*58b9f456SAndroid Build Coastguard Worker} 2722*58b9f456SAndroid Build Coastguard Worker 2723*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2724*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 2725*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, 2726*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 2727*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value>::type*) 2728*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2729*58b9f456SAndroid Build Coastguard Worker __size_(0), 2730*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0) 2731*58b9f456SAndroid Build Coastguard Worker{ 2732*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 2733*58b9f456SAndroid Build Coastguard Worker try 2734*58b9f456SAndroid Build Coastguard Worker { 2735*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 2736*58b9f456SAndroid Build Coastguard Worker for (; __first != __last; ++__first) 2737*58b9f456SAndroid Build Coastguard Worker push_back(*__first); 2738*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 2739*58b9f456SAndroid Build Coastguard Worker } 2740*58b9f456SAndroid Build Coastguard Worker catch (...) 2741*58b9f456SAndroid Build Coastguard Worker { 2742*58b9f456SAndroid Build Coastguard Worker if (__begin_ != nullptr) 2743*58b9f456SAndroid Build Coastguard Worker __storage_traits::deallocate(__alloc(), __begin_, __cap()); 2744*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 2745*58b9f456SAndroid Build Coastguard Worker throw; 2746*58b9f456SAndroid Build Coastguard Worker } 2747*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 2748*58b9f456SAndroid Build Coastguard Worker} 2749*58b9f456SAndroid Build Coastguard Worker 2750*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2751*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 2752*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, 2753*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_input_iterator <_InputIterator>::value && 2754*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value>::type*) 2755*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2756*58b9f456SAndroid Build Coastguard Worker __size_(0), 2757*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, static_cast<__storage_allocator>(__a)) 2758*58b9f456SAndroid Build Coastguard Worker{ 2759*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 2760*58b9f456SAndroid Build Coastguard Worker try 2761*58b9f456SAndroid Build Coastguard Worker { 2762*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 2763*58b9f456SAndroid Build Coastguard Worker for (; __first != __last; ++__first) 2764*58b9f456SAndroid Build Coastguard Worker push_back(*__first); 2765*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 2766*58b9f456SAndroid Build Coastguard Worker } 2767*58b9f456SAndroid Build Coastguard Worker catch (...) 2768*58b9f456SAndroid Build Coastguard Worker { 2769*58b9f456SAndroid Build Coastguard Worker if (__begin_ != nullptr) 2770*58b9f456SAndroid Build Coastguard Worker __storage_traits::deallocate(__alloc(), __begin_, __cap()); 2771*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 2772*58b9f456SAndroid Build Coastguard Worker throw; 2773*58b9f456SAndroid Build Coastguard Worker } 2774*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 2775*58b9f456SAndroid Build Coastguard Worker} 2776*58b9f456SAndroid Build Coastguard Worker 2777*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2778*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 2779*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, 2780*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) 2781*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2782*58b9f456SAndroid Build Coastguard Worker __size_(0), 2783*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0) 2784*58b9f456SAndroid Build Coastguard Worker{ 2785*58b9f456SAndroid Build Coastguard Worker size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 2786*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2787*58b9f456SAndroid Build Coastguard Worker { 2788*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2789*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__first, __last); 2790*58b9f456SAndroid Build Coastguard Worker } 2791*58b9f456SAndroid Build Coastguard Worker} 2792*58b9f456SAndroid Build Coastguard Worker 2793*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2794*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 2795*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, 2796*58b9f456SAndroid Build Coastguard Worker typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) 2797*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2798*58b9f456SAndroid Build Coastguard Worker __size_(0), 2799*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, static_cast<__storage_allocator>(__a)) 2800*58b9f456SAndroid Build Coastguard Worker{ 2801*58b9f456SAndroid Build Coastguard Worker size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 2802*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2803*58b9f456SAndroid Build Coastguard Worker { 2804*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2805*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__first, __last); 2806*58b9f456SAndroid Build Coastguard Worker } 2807*58b9f456SAndroid Build Coastguard Worker} 2808*58b9f456SAndroid Build Coastguard Worker 2809*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 2810*58b9f456SAndroid Build Coastguard Worker 2811*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2812*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(initializer_list<value_type> __il) 2813*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2814*58b9f456SAndroid Build Coastguard Worker __size_(0), 2815*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0) 2816*58b9f456SAndroid Build Coastguard Worker{ 2817*58b9f456SAndroid Build Coastguard Worker size_type __n = static_cast<size_type>(__il.size()); 2818*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2819*58b9f456SAndroid Build Coastguard Worker { 2820*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2821*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__il.begin(), __il.end()); 2822*58b9f456SAndroid Build Coastguard Worker } 2823*58b9f456SAndroid Build Coastguard Worker} 2824*58b9f456SAndroid Build Coastguard Worker 2825*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2826*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) 2827*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2828*58b9f456SAndroid Build Coastguard Worker __size_(0), 2829*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, static_cast<__storage_allocator>(__a)) 2830*58b9f456SAndroid Build Coastguard Worker{ 2831*58b9f456SAndroid Build Coastguard Worker size_type __n = static_cast<size_type>(__il.size()); 2832*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2833*58b9f456SAndroid Build Coastguard Worker { 2834*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 2835*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__il.begin(), __il.end()); 2836*58b9f456SAndroid Build Coastguard Worker } 2837*58b9f456SAndroid Build Coastguard Worker} 2838*58b9f456SAndroid Build Coastguard Worker 2839*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 2840*58b9f456SAndroid Build Coastguard Worker 2841*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2842*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::~vector() 2843*58b9f456SAndroid Build Coastguard Worker{ 2844*58b9f456SAndroid Build Coastguard Worker if (__begin_ != nullptr) 2845*58b9f456SAndroid Build Coastguard Worker __storage_traits::deallocate(__alloc(), __begin_, __cap()); 2846*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 2847*58b9f456SAndroid Build Coastguard Worker} 2848*58b9f456SAndroid Build Coastguard Worker 2849*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2850*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(const vector& __v) 2851*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2852*58b9f456SAndroid Build Coastguard Worker __size_(0), 2853*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) 2854*58b9f456SAndroid Build Coastguard Worker{ 2855*58b9f456SAndroid Build Coastguard Worker if (__v.size() > 0) 2856*58b9f456SAndroid Build Coastguard Worker { 2857*58b9f456SAndroid Build Coastguard Worker __vallocate(__v.size()); 2858*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__v.begin(), __v.end()); 2859*58b9f456SAndroid Build Coastguard Worker } 2860*58b9f456SAndroid Build Coastguard Worker} 2861*58b9f456SAndroid Build Coastguard Worker 2862*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2863*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) 2864*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2865*58b9f456SAndroid Build Coastguard Worker __size_(0), 2866*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, __a) 2867*58b9f456SAndroid Build Coastguard Worker{ 2868*58b9f456SAndroid Build Coastguard Worker if (__v.size() > 0) 2869*58b9f456SAndroid Build Coastguard Worker { 2870*58b9f456SAndroid Build Coastguard Worker __vallocate(__v.size()); 2871*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__v.begin(), __v.end()); 2872*58b9f456SAndroid Build Coastguard Worker } 2873*58b9f456SAndroid Build Coastguard Worker} 2874*58b9f456SAndroid Build Coastguard Worker 2875*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2876*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>& 2877*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::operator=(const vector& __v) 2878*58b9f456SAndroid Build Coastguard Worker{ 2879*58b9f456SAndroid Build Coastguard Worker if (this != &__v) 2880*58b9f456SAndroid Build Coastguard Worker { 2881*58b9f456SAndroid Build Coastguard Worker __copy_assign_alloc(__v); 2882*58b9f456SAndroid Build Coastguard Worker if (__v.__size_) 2883*58b9f456SAndroid Build Coastguard Worker { 2884*58b9f456SAndroid Build Coastguard Worker if (__v.__size_ > capacity()) 2885*58b9f456SAndroid Build Coastguard Worker { 2886*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 2887*58b9f456SAndroid Build Coastguard Worker __vallocate(__v.__size_); 2888*58b9f456SAndroid Build Coastguard Worker } 2889*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); 2890*58b9f456SAndroid Build Coastguard Worker } 2891*58b9f456SAndroid Build Coastguard Worker __size_ = __v.__size_; 2892*58b9f456SAndroid Build Coastguard Worker } 2893*58b9f456SAndroid Build Coastguard Worker return *this; 2894*58b9f456SAndroid Build Coastguard Worker} 2895*58b9f456SAndroid Build Coastguard Worker 2896*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 2897*58b9f456SAndroid Build Coastguard Worker 2898*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2899*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v) 2900*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 2901*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 2902*58b9f456SAndroid Build Coastguard Worker#else 2903*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) 2904*58b9f456SAndroid Build Coastguard Worker#endif 2905*58b9f456SAndroid Build Coastguard Worker : __begin_(__v.__begin_), 2906*58b9f456SAndroid Build Coastguard Worker __size_(__v.__size_), 2907*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(std::move(__v.__cap_alloc_)) { 2908*58b9f456SAndroid Build Coastguard Worker __v.__begin_ = nullptr; 2909*58b9f456SAndroid Build Coastguard Worker __v.__size_ = 0; 2910*58b9f456SAndroid Build Coastguard Worker __v.__cap() = 0; 2911*58b9f456SAndroid Build Coastguard Worker} 2912*58b9f456SAndroid Build Coastguard Worker 2913*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2914*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a) 2915*58b9f456SAndroid Build Coastguard Worker : __begin_(nullptr), 2916*58b9f456SAndroid Build Coastguard Worker __size_(0), 2917*58b9f456SAndroid Build Coastguard Worker __cap_alloc_(0, __a) 2918*58b9f456SAndroid Build Coastguard Worker{ 2919*58b9f456SAndroid Build Coastguard Worker if (__a == allocator_type(__v.__alloc())) 2920*58b9f456SAndroid Build Coastguard Worker { 2921*58b9f456SAndroid Build Coastguard Worker this->__begin_ = __v.__begin_; 2922*58b9f456SAndroid Build Coastguard Worker this->__size_ = __v.__size_; 2923*58b9f456SAndroid Build Coastguard Worker this->__cap() = __v.__cap(); 2924*58b9f456SAndroid Build Coastguard Worker __v.__begin_ = nullptr; 2925*58b9f456SAndroid Build Coastguard Worker __v.__cap() = __v.__size_ = 0; 2926*58b9f456SAndroid Build Coastguard Worker } 2927*58b9f456SAndroid Build Coastguard Worker else if (__v.size() > 0) 2928*58b9f456SAndroid Build Coastguard Worker { 2929*58b9f456SAndroid Build Coastguard Worker __vallocate(__v.size()); 2930*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__v.begin(), __v.end()); 2931*58b9f456SAndroid Build Coastguard Worker } 2932*58b9f456SAndroid Build Coastguard Worker} 2933*58b9f456SAndroid Build Coastguard Worker 2934*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2935*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 2936*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>& 2937*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::operator=(vector&& __v) 2938*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) 2939*58b9f456SAndroid Build Coastguard Worker{ 2940*58b9f456SAndroid Build Coastguard Worker __move_assign(__v, integral_constant<bool, 2941*58b9f456SAndroid Build Coastguard Worker __storage_traits::propagate_on_container_move_assignment::value>()); 2942*58b9f456SAndroid Build Coastguard Worker return *this; 2943*58b9f456SAndroid Build Coastguard Worker} 2944*58b9f456SAndroid Build Coastguard Worker 2945*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2946*58b9f456SAndroid Build Coastguard Workervoid 2947*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__move_assign(vector& __c, false_type) 2948*58b9f456SAndroid Build Coastguard Worker{ 2949*58b9f456SAndroid Build Coastguard Worker if (__alloc() != __c.__alloc()) 2950*58b9f456SAndroid Build Coastguard Worker assign(__c.begin(), __c.end()); 2951*58b9f456SAndroid Build Coastguard Worker else 2952*58b9f456SAndroid Build Coastguard Worker __move_assign(__c, true_type()); 2953*58b9f456SAndroid Build Coastguard Worker} 2954*58b9f456SAndroid Build Coastguard Worker 2955*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2956*58b9f456SAndroid Build Coastguard Workervoid 2957*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__move_assign(vector& __c, true_type) 2958*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 2959*58b9f456SAndroid Build Coastguard Worker{ 2960*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 2961*58b9f456SAndroid Build Coastguard Worker __move_assign_alloc(__c); 2962*58b9f456SAndroid Build Coastguard Worker this->__begin_ = __c.__begin_; 2963*58b9f456SAndroid Build Coastguard Worker this->__size_ = __c.__size_; 2964*58b9f456SAndroid Build Coastguard Worker this->__cap() = __c.__cap(); 2965*58b9f456SAndroid Build Coastguard Worker __c.__begin_ = nullptr; 2966*58b9f456SAndroid Build Coastguard Worker __c.__cap() = __c.__size_ = 0; 2967*58b9f456SAndroid Build Coastguard Worker} 2968*58b9f456SAndroid Build Coastguard Worker 2969*58b9f456SAndroid Build Coastguard Worker#endif // !_LIBCPP_CXX03_LANG 2970*58b9f456SAndroid Build Coastguard Worker 2971*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2972*58b9f456SAndroid Build Coastguard Workervoid 2973*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::assign(size_type __n, const value_type& __x) 2974*58b9f456SAndroid Build Coastguard Worker{ 2975*58b9f456SAndroid Build Coastguard Worker __size_ = 0; 2976*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 2977*58b9f456SAndroid Build Coastguard Worker { 2978*58b9f456SAndroid Build Coastguard Worker size_type __c = capacity(); 2979*58b9f456SAndroid Build Coastguard Worker if (__n <= __c) 2980*58b9f456SAndroid Build Coastguard Worker __size_ = __n; 2981*58b9f456SAndroid Build Coastguard Worker else 2982*58b9f456SAndroid Build Coastguard Worker { 2983*58b9f456SAndroid Build Coastguard Worker vector __v(__alloc()); 2984*58b9f456SAndroid Build Coastguard Worker __v.reserve(__recommend(__n)); 2985*58b9f456SAndroid Build Coastguard Worker __v.__size_ = __n; 2986*58b9f456SAndroid Build Coastguard Worker swap(__v); 2987*58b9f456SAndroid Build Coastguard Worker } 2988*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(begin(), __n, __x); 2989*58b9f456SAndroid Build Coastguard Worker } 2990*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 2991*58b9f456SAndroid Build Coastguard Worker} 2992*58b9f456SAndroid Build Coastguard Worker 2993*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 2994*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 2995*58b9f456SAndroid Build Coastguard Workertypename enable_if 2996*58b9f456SAndroid Build Coastguard Worker< 2997*58b9f456SAndroid Build Coastguard Worker __is_input_iterator<_InputIterator>::value && 2998*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value, 2999*58b9f456SAndroid Build Coastguard Worker void 3000*58b9f456SAndroid Build Coastguard Worker>::type 3001*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) 3002*58b9f456SAndroid Build Coastguard Worker{ 3003*58b9f456SAndroid Build Coastguard Worker clear(); 3004*58b9f456SAndroid Build Coastguard Worker for (; __first != __last; ++__first) 3005*58b9f456SAndroid Build Coastguard Worker push_back(*__first); 3006*58b9f456SAndroid Build Coastguard Worker} 3007*58b9f456SAndroid Build Coastguard Worker 3008*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3009*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 3010*58b9f456SAndroid Build Coastguard Workertypename enable_if 3011*58b9f456SAndroid Build Coastguard Worker< 3012*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 3013*58b9f456SAndroid Build Coastguard Worker void 3014*58b9f456SAndroid Build Coastguard Worker>::type 3015*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) 3016*58b9f456SAndroid Build Coastguard Worker{ 3017*58b9f456SAndroid Build Coastguard Worker clear(); 3018*58b9f456SAndroid Build Coastguard Worker difference_type __ns = _VSTD::distance(__first, __last); 3019*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__ns >= 0, "invalid range specified"); 3020*58b9f456SAndroid Build Coastguard Worker const size_t __n = static_cast<size_type>(__ns); 3021*58b9f456SAndroid Build Coastguard Worker if (__n) 3022*58b9f456SAndroid Build Coastguard Worker { 3023*58b9f456SAndroid Build Coastguard Worker if (__n > capacity()) 3024*58b9f456SAndroid Build Coastguard Worker { 3025*58b9f456SAndroid Build Coastguard Worker __vdeallocate(); 3026*58b9f456SAndroid Build Coastguard Worker __vallocate(__n); 3027*58b9f456SAndroid Build Coastguard Worker } 3028*58b9f456SAndroid Build Coastguard Worker __construct_at_end(__first, __last); 3029*58b9f456SAndroid Build Coastguard Worker } 3030*58b9f456SAndroid Build Coastguard Worker} 3031*58b9f456SAndroid Build Coastguard Worker 3032*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3033*58b9f456SAndroid Build Coastguard Workervoid 3034*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::reserve(size_type __n) 3035*58b9f456SAndroid Build Coastguard Worker{ 3036*58b9f456SAndroid Build Coastguard Worker if (__n > capacity()) 3037*58b9f456SAndroid Build Coastguard Worker { 3038*58b9f456SAndroid Build Coastguard Worker vector __v(this->__alloc()); 3039*58b9f456SAndroid Build Coastguard Worker __v.__vallocate(__n); 3040*58b9f456SAndroid Build Coastguard Worker __v.__construct_at_end(this->begin(), this->end()); 3041*58b9f456SAndroid Build Coastguard Worker swap(__v); 3042*58b9f456SAndroid Build Coastguard Worker __invalidate_all_iterators(); 3043*58b9f456SAndroid Build Coastguard Worker } 3044*58b9f456SAndroid Build Coastguard Worker} 3045*58b9f456SAndroid Build Coastguard Worker 3046*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3047*58b9f456SAndroid Build Coastguard Workervoid 3048*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT 3049*58b9f456SAndroid Build Coastguard Worker{ 3050*58b9f456SAndroid Build Coastguard Worker if (__external_cap_to_internal(size()) > __cap()) 3051*58b9f456SAndroid Build Coastguard Worker { 3052*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 3053*58b9f456SAndroid Build Coastguard Worker try 3054*58b9f456SAndroid Build Coastguard Worker { 3055*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 3056*58b9f456SAndroid Build Coastguard Worker vector(*this, allocator_type(__alloc())).swap(*this); 3057*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 3058*58b9f456SAndroid Build Coastguard Worker } 3059*58b9f456SAndroid Build Coastguard Worker catch (...) 3060*58b9f456SAndroid Build Coastguard Worker { 3061*58b9f456SAndroid Build Coastguard Worker } 3062*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 3063*58b9f456SAndroid Build Coastguard Worker } 3064*58b9f456SAndroid Build Coastguard Worker} 3065*58b9f456SAndroid Build Coastguard Worker 3066*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3067*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::reference 3068*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::at(size_type __n) 3069*58b9f456SAndroid Build Coastguard Worker{ 3070*58b9f456SAndroid Build Coastguard Worker if (__n >= size()) 3071*58b9f456SAndroid Build Coastguard Worker this->__throw_out_of_range(); 3072*58b9f456SAndroid Build Coastguard Worker return (*this)[__n]; 3073*58b9f456SAndroid Build Coastguard Worker} 3074*58b9f456SAndroid Build Coastguard Worker 3075*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3076*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::const_reference 3077*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::at(size_type __n) const 3078*58b9f456SAndroid Build Coastguard Worker{ 3079*58b9f456SAndroid Build Coastguard Worker if (__n >= size()) 3080*58b9f456SAndroid Build Coastguard Worker this->__throw_out_of_range(); 3081*58b9f456SAndroid Build Coastguard Worker return (*this)[__n]; 3082*58b9f456SAndroid Build Coastguard Worker} 3083*58b9f456SAndroid Build Coastguard Worker 3084*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3085*58b9f456SAndroid Build Coastguard Workervoid 3086*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::push_back(const value_type& __x) 3087*58b9f456SAndroid Build Coastguard Worker{ 3088*58b9f456SAndroid Build Coastguard Worker if (this->__size_ == this->capacity()) 3089*58b9f456SAndroid Build Coastguard Worker reserve(__recommend(this->__size_ + 1)); 3090*58b9f456SAndroid Build Coastguard Worker ++this->__size_; 3091*58b9f456SAndroid Build Coastguard Worker back() = __x; 3092*58b9f456SAndroid Build Coastguard Worker} 3093*58b9f456SAndroid Build Coastguard Worker 3094*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3095*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::iterator 3096*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) 3097*58b9f456SAndroid Build Coastguard Worker{ 3098*58b9f456SAndroid Build Coastguard Worker iterator __r; 3099*58b9f456SAndroid Build Coastguard Worker if (size() < capacity()) 3100*58b9f456SAndroid Build Coastguard Worker { 3101*58b9f456SAndroid Build Coastguard Worker const_iterator __old_end = end(); 3102*58b9f456SAndroid Build Coastguard Worker ++__size_; 3103*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(__position, __old_end, end()); 3104*58b9f456SAndroid Build Coastguard Worker __r = __const_iterator_cast(__position); 3105*58b9f456SAndroid Build Coastguard Worker } 3106*58b9f456SAndroid Build Coastguard Worker else 3107*58b9f456SAndroid Build Coastguard Worker { 3108*58b9f456SAndroid Build Coastguard Worker vector __v(__alloc()); 3109*58b9f456SAndroid Build Coastguard Worker __v.reserve(__recommend(__size_ + 1)); 3110*58b9f456SAndroid Build Coastguard Worker __v.__size_ = __size_ + 1; 3111*58b9f456SAndroid Build Coastguard Worker __r = _VSTD::copy(cbegin(), __position, __v.begin()); 3112*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(__position, cend(), __v.end()); 3113*58b9f456SAndroid Build Coastguard Worker swap(__v); 3114*58b9f456SAndroid Build Coastguard Worker } 3115*58b9f456SAndroid Build Coastguard Worker *__r = __x; 3116*58b9f456SAndroid Build Coastguard Worker return __r; 3117*58b9f456SAndroid Build Coastguard Worker} 3118*58b9f456SAndroid Build Coastguard Worker 3119*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3120*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::iterator 3121*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) 3122*58b9f456SAndroid Build Coastguard Worker{ 3123*58b9f456SAndroid Build Coastguard Worker iterator __r; 3124*58b9f456SAndroid Build Coastguard Worker size_type __c = capacity(); 3125*58b9f456SAndroid Build Coastguard Worker if (__n <= __c && size() <= __c - __n) 3126*58b9f456SAndroid Build Coastguard Worker { 3127*58b9f456SAndroid Build Coastguard Worker const_iterator __old_end = end(); 3128*58b9f456SAndroid Build Coastguard Worker __size_ += __n; 3129*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(__position, __old_end, end()); 3130*58b9f456SAndroid Build Coastguard Worker __r = __const_iterator_cast(__position); 3131*58b9f456SAndroid Build Coastguard Worker } 3132*58b9f456SAndroid Build Coastguard Worker else 3133*58b9f456SAndroid Build Coastguard Worker { 3134*58b9f456SAndroid Build Coastguard Worker vector __v(__alloc()); 3135*58b9f456SAndroid Build Coastguard Worker __v.reserve(__recommend(__size_ + __n)); 3136*58b9f456SAndroid Build Coastguard Worker __v.__size_ = __size_ + __n; 3137*58b9f456SAndroid Build Coastguard Worker __r = _VSTD::copy(cbegin(), __position, __v.begin()); 3138*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(__position, cend(), __v.end()); 3139*58b9f456SAndroid Build Coastguard Worker swap(__v); 3140*58b9f456SAndroid Build Coastguard Worker } 3141*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(__r, __n, __x); 3142*58b9f456SAndroid Build Coastguard Worker return __r; 3143*58b9f456SAndroid Build Coastguard Worker} 3144*58b9f456SAndroid Build Coastguard Worker 3145*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3146*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator> 3147*58b9f456SAndroid Build Coastguard Workertypename enable_if 3148*58b9f456SAndroid Build Coastguard Worker< 3149*58b9f456SAndroid Build Coastguard Worker __is_input_iterator <_InputIterator>::value && 3150*58b9f456SAndroid Build Coastguard Worker !__is_forward_iterator<_InputIterator>::value, 3151*58b9f456SAndroid Build Coastguard Worker typename vector<bool, _Allocator>::iterator 3152*58b9f456SAndroid Build Coastguard Worker>::type 3153*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) 3154*58b9f456SAndroid Build Coastguard Worker{ 3155*58b9f456SAndroid Build Coastguard Worker difference_type __off = __position - begin(); 3156*58b9f456SAndroid Build Coastguard Worker iterator __p = __const_iterator_cast(__position); 3157*58b9f456SAndroid Build Coastguard Worker iterator __old_end = end(); 3158*58b9f456SAndroid Build Coastguard Worker for (; size() != capacity() && __first != __last; ++__first) 3159*58b9f456SAndroid Build Coastguard Worker { 3160*58b9f456SAndroid Build Coastguard Worker ++this->__size_; 3161*58b9f456SAndroid Build Coastguard Worker back() = *__first; 3162*58b9f456SAndroid Build Coastguard Worker } 3163*58b9f456SAndroid Build Coastguard Worker vector __v(__alloc()); 3164*58b9f456SAndroid Build Coastguard Worker if (__first != __last) 3165*58b9f456SAndroid Build Coastguard Worker { 3166*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 3167*58b9f456SAndroid Build Coastguard Worker try 3168*58b9f456SAndroid Build Coastguard Worker { 3169*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 3170*58b9f456SAndroid Build Coastguard Worker __v.assign(__first, __last); 3171*58b9f456SAndroid Build Coastguard Worker difference_type __old_size = static_cast<difference_type>(__old_end - begin()); 3172*58b9f456SAndroid Build Coastguard Worker difference_type __old_p = __p - begin(); 3173*58b9f456SAndroid Build Coastguard Worker reserve(__recommend(size() + __v.size())); 3174*58b9f456SAndroid Build Coastguard Worker __p = begin() + __old_p; 3175*58b9f456SAndroid Build Coastguard Worker __old_end = begin() + __old_size; 3176*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 3177*58b9f456SAndroid Build Coastguard Worker } 3178*58b9f456SAndroid Build Coastguard Worker catch (...) 3179*58b9f456SAndroid Build Coastguard Worker { 3180*58b9f456SAndroid Build Coastguard Worker erase(__old_end, end()); 3181*58b9f456SAndroid Build Coastguard Worker throw; 3182*58b9f456SAndroid Build Coastguard Worker } 3183*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 3184*58b9f456SAndroid Build Coastguard Worker } 3185*58b9f456SAndroid Build Coastguard Worker __p = _VSTD::rotate(__p, __old_end, end()); 3186*58b9f456SAndroid Build Coastguard Worker insert(__p, __v.begin(), __v.end()); 3187*58b9f456SAndroid Build Coastguard Worker return begin() + __off; 3188*58b9f456SAndroid Build Coastguard Worker} 3189*58b9f456SAndroid Build Coastguard Worker 3190*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3191*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator> 3192*58b9f456SAndroid Build Coastguard Workertypename enable_if 3193*58b9f456SAndroid Build Coastguard Worker< 3194*58b9f456SAndroid Build Coastguard Worker __is_forward_iterator<_ForwardIterator>::value, 3195*58b9f456SAndroid Build Coastguard Worker typename vector<bool, _Allocator>::iterator 3196*58b9f456SAndroid Build Coastguard Worker>::type 3197*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) 3198*58b9f456SAndroid Build Coastguard Worker{ 3199*58b9f456SAndroid Build Coastguard Worker const difference_type __n_signed = _VSTD::distance(__first, __last); 3200*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified"); 3201*58b9f456SAndroid Build Coastguard Worker const size_type __n = static_cast<size_type>(__n_signed); 3202*58b9f456SAndroid Build Coastguard Worker iterator __r; 3203*58b9f456SAndroid Build Coastguard Worker size_type __c = capacity(); 3204*58b9f456SAndroid Build Coastguard Worker if (__n <= __c && size() <= __c - __n) 3205*58b9f456SAndroid Build Coastguard Worker { 3206*58b9f456SAndroid Build Coastguard Worker const_iterator __old_end = end(); 3207*58b9f456SAndroid Build Coastguard Worker __size_ += __n; 3208*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(__position, __old_end, end()); 3209*58b9f456SAndroid Build Coastguard Worker __r = __const_iterator_cast(__position); 3210*58b9f456SAndroid Build Coastguard Worker } 3211*58b9f456SAndroid Build Coastguard Worker else 3212*58b9f456SAndroid Build Coastguard Worker { 3213*58b9f456SAndroid Build Coastguard Worker vector __v(__alloc()); 3214*58b9f456SAndroid Build Coastguard Worker __v.reserve(__recommend(__size_ + __n)); 3215*58b9f456SAndroid Build Coastguard Worker __v.__size_ = __size_ + __n; 3216*58b9f456SAndroid Build Coastguard Worker __r = _VSTD::copy(cbegin(), __position, __v.begin()); 3217*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(__position, cend(), __v.end()); 3218*58b9f456SAndroid Build Coastguard Worker swap(__v); 3219*58b9f456SAndroid Build Coastguard Worker } 3220*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__first, __last, __r); 3221*58b9f456SAndroid Build Coastguard Worker return __r; 3222*58b9f456SAndroid Build Coastguard Worker} 3223*58b9f456SAndroid Build Coastguard Worker 3224*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3225*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3226*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::iterator 3227*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::erase(const_iterator __position) 3228*58b9f456SAndroid Build Coastguard Worker{ 3229*58b9f456SAndroid Build Coastguard Worker iterator __r = __const_iterator_cast(__position); 3230*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__position + 1, this->cend(), __r); 3231*58b9f456SAndroid Build Coastguard Worker --__size_; 3232*58b9f456SAndroid Build Coastguard Worker return __r; 3233*58b9f456SAndroid Build Coastguard Worker} 3234*58b9f456SAndroid Build Coastguard Worker 3235*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3236*58b9f456SAndroid Build Coastguard Workertypename vector<bool, _Allocator>::iterator 3237*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) 3238*58b9f456SAndroid Build Coastguard Worker{ 3239*58b9f456SAndroid Build Coastguard Worker iterator __r = __const_iterator_cast(__first); 3240*58b9f456SAndroid Build Coastguard Worker difference_type __d = __last - __first; 3241*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__last, this->cend(), __r); 3242*58b9f456SAndroid Build Coastguard Worker __size_ -= __d; 3243*58b9f456SAndroid Build Coastguard Worker return __r; 3244*58b9f456SAndroid Build Coastguard Worker} 3245*58b9f456SAndroid Build Coastguard Worker 3246*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3247*58b9f456SAndroid Build Coastguard Workervoid 3248*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::swap(vector& __x) 3249*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14 3250*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT 3251*58b9f456SAndroid Build Coastguard Worker#else 3252*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 3253*58b9f456SAndroid Build Coastguard Worker __is_nothrow_swappable<allocator_type>::value) 3254*58b9f456SAndroid Build Coastguard Worker#endif 3255*58b9f456SAndroid Build Coastguard Worker{ 3256*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__begin_, __x.__begin_); 3257*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__size_, __x.__size_); 3258*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(this->__cap(), __x.__cap()); 3259*58b9f456SAndroid Build Coastguard Worker __swap_allocator(this->__alloc(), __x.__alloc(), 3260*58b9f456SAndroid Build Coastguard Worker integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); 3261*58b9f456SAndroid Build Coastguard Worker} 3262*58b9f456SAndroid Build Coastguard Worker 3263*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3264*58b9f456SAndroid Build Coastguard Workervoid 3265*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::resize(size_type __sz, value_type __x) 3266*58b9f456SAndroid Build Coastguard Worker{ 3267*58b9f456SAndroid Build Coastguard Worker size_type __cs = size(); 3268*58b9f456SAndroid Build Coastguard Worker if (__cs < __sz) 3269*58b9f456SAndroid Build Coastguard Worker { 3270*58b9f456SAndroid Build Coastguard Worker iterator __r; 3271*58b9f456SAndroid Build Coastguard Worker size_type __c = capacity(); 3272*58b9f456SAndroid Build Coastguard Worker size_type __n = __sz - __cs; 3273*58b9f456SAndroid Build Coastguard Worker if (__n <= __c && __cs <= __c - __n) 3274*58b9f456SAndroid Build Coastguard Worker { 3275*58b9f456SAndroid Build Coastguard Worker __r = end(); 3276*58b9f456SAndroid Build Coastguard Worker __size_ += __n; 3277*58b9f456SAndroid Build Coastguard Worker } 3278*58b9f456SAndroid Build Coastguard Worker else 3279*58b9f456SAndroid Build Coastguard Worker { 3280*58b9f456SAndroid Build Coastguard Worker vector __v(__alloc()); 3281*58b9f456SAndroid Build Coastguard Worker __v.reserve(__recommend(__size_ + __n)); 3282*58b9f456SAndroid Build Coastguard Worker __v.__size_ = __size_ + __n; 3283*58b9f456SAndroid Build Coastguard Worker __r = _VSTD::copy(cbegin(), cend(), __v.begin()); 3284*58b9f456SAndroid Build Coastguard Worker swap(__v); 3285*58b9f456SAndroid Build Coastguard Worker } 3286*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(__r, __n, __x); 3287*58b9f456SAndroid Build Coastguard Worker } 3288*58b9f456SAndroid Build Coastguard Worker else 3289*58b9f456SAndroid Build Coastguard Worker __size_ = __sz; 3290*58b9f456SAndroid Build Coastguard Worker} 3291*58b9f456SAndroid Build Coastguard Worker 3292*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3293*58b9f456SAndroid Build Coastguard Workervoid 3294*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::flip() _NOEXCEPT 3295*58b9f456SAndroid Build Coastguard Worker{ 3296*58b9f456SAndroid Build Coastguard Worker // do middle whole words 3297*58b9f456SAndroid Build Coastguard Worker size_type __n = __size_; 3298*58b9f456SAndroid Build Coastguard Worker __storage_pointer __p = __begin_; 3299*58b9f456SAndroid Build Coastguard Worker for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 3300*58b9f456SAndroid Build Coastguard Worker *__p = ~*__p; 3301*58b9f456SAndroid Build Coastguard Worker // do last partial word 3302*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 3303*58b9f456SAndroid Build Coastguard Worker { 3304*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 3305*58b9f456SAndroid Build Coastguard Worker __storage_type __b = *__p & __m; 3306*58b9f456SAndroid Build Coastguard Worker *__p &= ~__m; 3307*58b9f456SAndroid Build Coastguard Worker *__p |= ~__b & __m; 3308*58b9f456SAndroid Build Coastguard Worker } 3309*58b9f456SAndroid Build Coastguard Worker} 3310*58b9f456SAndroid Build Coastguard Worker 3311*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3312*58b9f456SAndroid Build Coastguard Workerbool 3313*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__invariants() const 3314*58b9f456SAndroid Build Coastguard Worker{ 3315*58b9f456SAndroid Build Coastguard Worker if (this->__begin_ == nullptr) 3316*58b9f456SAndroid Build Coastguard Worker { 3317*58b9f456SAndroid Build Coastguard Worker if (this->__size_ != 0 || this->__cap() != 0) 3318*58b9f456SAndroid Build Coastguard Worker return false; 3319*58b9f456SAndroid Build Coastguard Worker } 3320*58b9f456SAndroid Build Coastguard Worker else 3321*58b9f456SAndroid Build Coastguard Worker { 3322*58b9f456SAndroid Build Coastguard Worker if (this->__cap() == 0) 3323*58b9f456SAndroid Build Coastguard Worker return false; 3324*58b9f456SAndroid Build Coastguard Worker if (this->__size_ > this->capacity()) 3325*58b9f456SAndroid Build Coastguard Worker return false; 3326*58b9f456SAndroid Build Coastguard Worker } 3327*58b9f456SAndroid Build Coastguard Worker return true; 3328*58b9f456SAndroid Build Coastguard Worker} 3329*58b9f456SAndroid Build Coastguard Worker 3330*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3331*58b9f456SAndroid Build Coastguard Workersize_t 3332*58b9f456SAndroid Build Coastguard Workervector<bool, _Allocator>::__hash_code() const _NOEXCEPT 3333*58b9f456SAndroid Build Coastguard Worker{ 3334*58b9f456SAndroid Build Coastguard Worker size_t __h = 0; 3335*58b9f456SAndroid Build Coastguard Worker // do middle whole words 3336*58b9f456SAndroid Build Coastguard Worker size_type __n = __size_; 3337*58b9f456SAndroid Build Coastguard Worker __storage_pointer __p = __begin_; 3338*58b9f456SAndroid Build Coastguard Worker for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 3339*58b9f456SAndroid Build Coastguard Worker __h ^= *__p; 3340*58b9f456SAndroid Build Coastguard Worker // do last partial word 3341*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 3342*58b9f456SAndroid Build Coastguard Worker { 3343*58b9f456SAndroid Build Coastguard Worker const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 3344*58b9f456SAndroid Build Coastguard Worker __h ^= *__p & __m; 3345*58b9f456SAndroid Build Coastguard Worker } 3346*58b9f456SAndroid Build Coastguard Worker return __h; 3347*58b9f456SAndroid Build Coastguard Worker} 3348*58b9f456SAndroid Build Coastguard Worker 3349*58b9f456SAndroid Build Coastguard Workertemplate <class _Allocator> 3350*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > 3351*58b9f456SAndroid Build Coastguard Worker : public unary_function<vector<bool, _Allocator>, size_t> 3352*58b9f456SAndroid Build Coastguard Worker{ 3353*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 3354*58b9f456SAndroid Build Coastguard Worker size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT 3355*58b9f456SAndroid Build Coastguard Worker {return __vec.__hash_code();} 3356*58b9f456SAndroid Build Coastguard Worker}; 3357*58b9f456SAndroid Build Coastguard Worker 3358*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3359*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3360*58b9f456SAndroid Build Coastguard Workerbool 3361*58b9f456SAndroid Build Coastguard Workeroperator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) 3362*58b9f456SAndroid Build Coastguard Worker{ 3363*58b9f456SAndroid Build Coastguard Worker const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); 3364*58b9f456SAndroid Build Coastguard Worker return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 3365*58b9f456SAndroid Build Coastguard Worker} 3366*58b9f456SAndroid Build Coastguard Worker 3367*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3368*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3369*58b9f456SAndroid Build Coastguard Workerbool 3370*58b9f456SAndroid Build Coastguard Workeroperator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) 3371*58b9f456SAndroid Build Coastguard Worker{ 3372*58b9f456SAndroid Build Coastguard Worker return !(__x == __y); 3373*58b9f456SAndroid Build Coastguard Worker} 3374*58b9f456SAndroid Build Coastguard Worker 3375*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3376*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3377*58b9f456SAndroid Build Coastguard Workerbool 3378*58b9f456SAndroid Build Coastguard Workeroperator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) 3379*58b9f456SAndroid Build Coastguard Worker{ 3380*58b9f456SAndroid Build Coastguard Worker return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 3381*58b9f456SAndroid Build Coastguard Worker} 3382*58b9f456SAndroid Build Coastguard Worker 3383*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3384*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3385*58b9f456SAndroid Build Coastguard Workerbool 3386*58b9f456SAndroid Build Coastguard Workeroperator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) 3387*58b9f456SAndroid Build Coastguard Worker{ 3388*58b9f456SAndroid Build Coastguard Worker return __y < __x; 3389*58b9f456SAndroid Build Coastguard Worker} 3390*58b9f456SAndroid Build Coastguard Worker 3391*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3392*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3393*58b9f456SAndroid Build Coastguard Workerbool 3394*58b9f456SAndroid Build Coastguard Workeroperator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) 3395*58b9f456SAndroid Build Coastguard Worker{ 3396*58b9f456SAndroid Build Coastguard Worker return !(__x < __y); 3397*58b9f456SAndroid Build Coastguard Worker} 3398*58b9f456SAndroid Build Coastguard Worker 3399*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3400*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3401*58b9f456SAndroid Build Coastguard Workerbool 3402*58b9f456SAndroid Build Coastguard Workeroperator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) 3403*58b9f456SAndroid Build Coastguard Worker{ 3404*58b9f456SAndroid Build Coastguard Worker return !(__y < __x); 3405*58b9f456SAndroid Build Coastguard Worker} 3406*58b9f456SAndroid Build Coastguard Worker 3407*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator> 3408*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3409*58b9f456SAndroid Build Coastguard Workervoid 3410*58b9f456SAndroid Build Coastguard Workerswap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) 3411*58b9f456SAndroid Build Coastguard Worker _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 3412*58b9f456SAndroid Build Coastguard Worker{ 3413*58b9f456SAndroid Build Coastguard Worker __x.swap(__y); 3414*58b9f456SAndroid Build Coastguard Worker} 3415*58b9f456SAndroid Build Coastguard Worker 3416*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17 3417*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator, class _Up> 3418*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3419*58b9f456SAndroid Build Coastguard Workervoid erase(vector<_Tp, _Allocator>& __c, const _Up& __v) 3420*58b9f456SAndroid Build Coastguard Worker{ __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); } 3421*58b9f456SAndroid Build Coastguard Worker 3422*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator, class _Predicate> 3423*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 3424*58b9f456SAndroid Build Coastguard Workervoid erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) 3425*58b9f456SAndroid Build Coastguard Worker{ __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); } 3426*58b9f456SAndroid Build Coastguard Worker#endif 3427*58b9f456SAndroid Build Coastguard Worker 3428*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD 3429*58b9f456SAndroid Build Coastguard Worker 3430*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS 3431*58b9f456SAndroid Build Coastguard Worker 3432*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_VECTOR 3433