1 // Like the compiler, the static analyzer treats some functions differently if
2 // they come from a system header -- for example, it is assumed that system
3 // functions do not arbitrarily free() their parameters, and that some bugs
4 // found in system headers cannot be fixed by the user and should be
6 #pragma clang system_header
8 typedef unsigned char uint8_t;
10 typedef __typeof__(sizeof(int)) size_t;
11 typedef __typeof__((char*)0-(char*)0) ptrdiff_t;
12 void *memmove(void *s1
, const void *s2
, size_t n
);
15 typedef size_t size_type
;
16 #if __cplusplus >= 201103L
17 using nullptr_t
= decltype(nullptr);
22 struct input_iterator_tag
{ };
23 struct output_iterator_tag
{ };
24 struct forward_iterator_tag
: public input_iterator_tag
{ };
25 struct bidirectional_iterator_tag
: public forward_iterator_tag
{ };
26 struct random_access_iterator_tag
: public bidirectional_iterator_tag
{ };
28 template <typename Iterator
> struct iterator_traits
{
29 typedef typename
Iterator::difference_type difference_type
;
30 typedef typename
Iterator::value_type value_type
;
31 typedef typename
Iterator::pointer pointer
;
32 typedef typename
Iterator::reference reference
;
33 typedef typename
Iterator::iterator_category iterator_category
;
37 template <typename T
, typename Ptr
, typename Ref
> struct __vector_iterator
{
38 typedef __vector_iterator
<T
, T
*, T
&> iterator
;
39 typedef __vector_iterator
<T
, const T
*, const T
&> const_iterator
;
41 typedef ptrdiff_t difference_type
;
44 typedef Ref reference
;
45 typedef std::random_access_iterator_tag iterator_category
;
47 __vector_iterator(const Ptr p
= 0) : ptr(p
) {}
48 __vector_iterator(const iterator
&rhs
): ptr(rhs
.base()) {}
49 __vector_iterator
<T
, Ptr
, Ref
>& operator++() { ++ ptr
; return *this; }
50 __vector_iterator
<T
, Ptr
, Ref
> operator++(int) {
55 __vector_iterator
<T
, Ptr
, Ref
> operator--() { -- ptr
; return *this; }
56 __vector_iterator
<T
, Ptr
, Ref
> operator--(int) {
57 auto tmp
= *this; -- ptr
;
60 __vector_iterator
<T
, Ptr
, Ref
> operator+(difference_type n
) {
63 friend __vector_iterator
<T
, Ptr
, Ref
> operator+(
65 const __vector_iterator
<T
, Ptr
, Ref
> &iter
) {
68 __vector_iterator
<T
, Ptr
, Ref
> operator-(difference_type n
) {
71 __vector_iterator
<T
, Ptr
, Ref
> operator+=(difference_type n
) {
74 __vector_iterator
<T
, Ptr
, Ref
> operator-=(difference_type n
) {
78 template<typename U
, typename Ptr2
, typename Ref2
>
79 difference_type
operator-(const __vector_iterator
<U
, Ptr2
, Ref2
> &rhs
);
81 Ref
operator*() const { return *ptr
; }
82 Ptr
operator->() const { return ptr
; }
84 Ref
operator[](difference_type n
) {
88 bool operator==(const iterator
&rhs
) const { return ptr
== rhs
.ptr
; }
89 bool operator==(const const_iterator
&rhs
) const { return ptr
== rhs
.ptr
; }
91 bool operator!=(const iterator
&rhs
) const { return ptr
!= rhs
.ptr
; }
92 bool operator!=(const const_iterator
&rhs
) const { return ptr
!= rhs
.ptr
; }
94 const Ptr
& base() const { return ptr
; }
100 template <typename T
, typename Ptr
, typename Ref
> struct __deque_iterator
{
101 typedef __deque_iterator
<T
, T
*, T
&> iterator
;
102 typedef __deque_iterator
<T
, const T
*, const T
&> const_iterator
;
104 typedef ptrdiff_t difference_type
;
105 typedef T value_type
;
107 typedef Ref reference
;
108 typedef std::random_access_iterator_tag iterator_category
;
110 __deque_iterator(const Ptr p
= 0) : ptr(p
) {}
111 __deque_iterator(const iterator
&rhs
): ptr(rhs
.base()) {}
112 __deque_iterator
<T
, Ptr
, Ref
>& operator++() { ++ ptr
; return *this; }
113 __deque_iterator
<T
, Ptr
, Ref
> operator++(int) {
118 __deque_iterator
<T
, Ptr
, Ref
> operator--() { -- ptr
; return *this; }
119 __deque_iterator
<T
, Ptr
, Ref
> operator--(int) {
120 auto tmp
= *this; -- ptr
;
123 __deque_iterator
<T
, Ptr
, Ref
> operator+(difference_type n
) {
126 friend __deque_iterator
<T
, Ptr
, Ref
> operator+(
128 const __deque_iterator
<T
, Ptr
, Ref
> &iter
) {
131 __deque_iterator
<T
, Ptr
, Ref
> operator-(difference_type n
) {
134 __deque_iterator
<T
, Ptr
, Ref
> operator+=(difference_type n
) {
137 __deque_iterator
<T
, Ptr
, Ref
> operator-=(difference_type n
) {
141 Ref
operator*() const { return *ptr
; }
142 Ptr
operator->() const { return ptr
; }
144 Ref
operator[](difference_type n
) {
148 bool operator==(const iterator
&rhs
) const { return ptr
== rhs
.ptr
; }
149 bool operator==(const const_iterator
&rhs
) const { return ptr
== rhs
.ptr
; }
151 bool operator!=(const iterator
&rhs
) const { return ptr
!= rhs
.ptr
; }
152 bool operator!=(const const_iterator
&rhs
) const { return ptr
!= rhs
.ptr
; }
154 const Ptr
& base() const { return ptr
; }
160 template <typename T
, typename Ptr
, typename Ref
> struct __list_iterator
{
161 typedef __list_iterator
<T
, __typeof__(T::data
) *, __typeof__(T::data
) &> iterator
;
162 typedef __list_iterator
<T
, const __typeof__(T::data
) *, const __typeof__(T::data
) &> const_iterator
;
164 typedef ptrdiff_t difference_type
;
165 typedef T value_type
;
167 typedef Ref reference
;
168 typedef std::bidirectional_iterator_tag iterator_category
;
170 __list_iterator(T
* it
= 0) : item(it
) {}
171 __list_iterator(const iterator
&rhs
): item(rhs
.item
) {}
172 __list_iterator
<T
, Ptr
, Ref
>& operator++() { item
= item
->next
; return *this; }
173 __list_iterator
<T
, Ptr
, Ref
> operator++(int) {
178 __list_iterator
<T
, Ptr
, Ref
> operator--() { item
= item
->prev
; return *this; }
179 __list_iterator
<T
, Ptr
, Ref
> operator--(int) {
185 Ref
operator*() const { return item
->data
; }
186 Ptr
operator->() const { return &item
->data
; }
188 bool operator==(const iterator
&rhs
) const { return item
== rhs
->item
; }
189 bool operator==(const const_iterator
&rhs
) const { return item
== rhs
->item
; }
191 bool operator!=(const iterator
&rhs
) const { return item
!= rhs
->item
; }
192 bool operator!=(const const_iterator
&rhs
) const { return item
!= rhs
->item
; }
194 const T
* &base() const { return item
; }
196 template <typename UT
, typename UPtr
, typename URef
>
197 friend struct __list_iterator
;
203 template <typename T
, typename Ptr
, typename Ref
> struct __fwdl_iterator
{
204 typedef __fwdl_iterator
<T
, __typeof__(T::data
) *, __typeof__(T::data
) &> iterator
;
205 typedef __fwdl_iterator
<T
, const __typeof__(T::data
) *, const __typeof__(T::data
) &> const_iterator
;
207 typedef ptrdiff_t difference_type
;
208 typedef T value_type
;
210 typedef Ref reference
;
211 typedef std::forward_iterator_tag iterator_category
;
213 __fwdl_iterator(T
* it
= 0) : item(it
) {}
214 __fwdl_iterator(const iterator
&rhs
): item(rhs
.item
) {}
215 __fwdl_iterator
<T
, Ptr
, Ref
>& operator++() { item
= item
->next
; return *this; }
216 __fwdl_iterator
<T
, Ptr
, Ref
> operator++(int) {
221 Ref
operator*() const { return item
->data
; }
222 Ptr
operator->() const { return &item
->data
; }
224 bool operator==(const iterator
&rhs
) const { return item
== rhs
->item
; }
225 bool operator==(const const_iterator
&rhs
) const { return item
== rhs
->item
; }
227 bool operator!=(const iterator
&rhs
) const { return item
!= rhs
->item
; }
228 bool operator!=(const const_iterator
&rhs
) const { return item
!= rhs
->item
; }
230 const T
* &base() const { return item
; }
232 template <typename UT
, typename UPtr
, typename URef
>
233 friend struct __fwdl_iterator
;
240 template <class T1
, class T2
>
245 pair() : first(), second() {}
246 pair(const T1
&a
, const T2
&b
) : first(a
), second(b
) {}
248 template<class U1
, class U2
>
249 pair(const pair
<U1
, U2
> &other
) : first(other
.first
),
250 second(other
.second
) {}
253 typedef __typeof__(sizeof(int)) size_t;
255 template <class T
> class initializer_list
;
257 template< class T
> struct remove_reference
{typedef T type
;};
258 template< class T
> struct remove_reference
<T
&> {typedef T type
;};
259 template< class T
> struct remove_reference
<T
&&> {typedef T type
;};
262 typename remove_reference
<T
>::type
&& move(T
&& a
) {
263 typedef typename remove_reference
<T
>::type
&& RvalRef
;
264 return static_cast<RvalRef
>(a
);
268 void swap(T
&a
, T
&b
) {
281 typedef T value_type
;
282 typedef size_t size_type
;
283 typedef __vector_iterator
<T
, T
*, T
&> iterator
;
284 typedef __vector_iterator
<T
, const T
*, const T
&> const_iterator
;
286 vector() : _start(0), _finish(0), _end_of_storage(0) {}
287 template <typename InputIterator
>
288 vector(InputIterator first
, InputIterator last
);
289 vector(const vector
&other
);
290 vector(vector
&&other
);
293 size_t size() const {
294 return size_t(_finish
- _start
);
297 vector
& operator=(const vector
&other
);
298 vector
& operator=(vector
&&other
);
299 vector
& operator=(std::initializer_list
<T
> ilist
);
301 void assign(size_type count
, const T
&value
);
302 template <typename InputIterator
>
303 void assign(InputIterator first
, InputIterator last
);
304 void assign(std::initializer_list
<T
> ilist
);
308 void push_back(const T
&value
);
309 void push_back(T
&&value
);
310 template<class... Args
>
311 void emplace_back(Args
&&... args
);
314 iterator
insert(const_iterator position
, const value_type
&val
);
315 iterator
insert(const_iterator position
, size_type n
,
316 const value_type
&val
);
317 template <typename InputIterator
>
318 iterator
insert(const_iterator position
, InputIterator first
,
320 iterator
insert(const_iterator position
, value_type
&&val
);
321 iterator
insert(const_iterator position
, initializer_list
<value_type
> il
);
323 template <class... Args
>
324 iterator
emplace(const_iterator position
, Args
&&... args
);
326 iterator
erase(const_iterator position
);
327 iterator
erase(const_iterator first
, const_iterator last
);
329 T
&operator[](size_t n
) {
333 const T
&operator[](size_t n
) const {
337 iterator
begin() { return iterator(_start
); }
338 const_iterator
begin() const { return const_iterator(_start
); }
339 const_iterator
cbegin() const { return const_iterator(_start
); }
340 iterator
end() { return iterator(_finish
); }
341 const_iterator
end() const { return const_iterator(_finish
); }
342 const_iterator
cend() const { return const_iterator(_finish
); }
343 T
& front() { return *begin(); }
344 const T
& front() const { return *begin(); }
345 T
& back() { return *(end() - 1); }
346 const T
& back() const { return *(end() - 1); }
357 typedef T value_type
;
358 typedef size_t size_type
;
359 typedef __list_iterator
<__item
, T
*, T
&> iterator
;
360 typedef __list_iterator
<__item
, const T
*, const T
&> const_iterator
;
362 list() : _start(0), _finish(0) {}
363 template <typename InputIterator
>
364 list(InputIterator first
, InputIterator last
);
365 list(const list
&other
);
369 list
& operator=(const list
&other
);
370 list
& operator=(list
&&other
);
371 list
& operator=(std::initializer_list
<T
> ilist
);
373 void assign(size_type count
, const T
&value
);
374 template <typename InputIterator
>
375 void assign(InputIterator first
, InputIterator last
);
376 void assign(std::initializer_list
<T
> ilist
);
380 void push_back(const T
&value
);
381 void push_back(T
&&value
);
382 template<class... Args
>
383 void emplace_back(Args
&&... args
);
386 void push_front(const T
&value
);
387 void push_front(T
&&value
);
388 template<class... Args
>
389 void emplace_front(Args
&&... args
);
392 iterator
insert(const_iterator position
, const value_type
&val
);
393 iterator
insert(const_iterator position
, size_type n
,
394 const value_type
&val
);
395 template <typename InputIterator
>
396 iterator
insert(const_iterator position
, InputIterator first
,
398 iterator
insert(const_iterator position
, value_type
&&val
);
399 iterator
insert(const_iterator position
, initializer_list
<value_type
> il
);
401 template <class... Args
>
402 iterator
emplace(const_iterator position
, Args
&&... args
);
404 iterator
erase(const_iterator position
);
405 iterator
erase(const_iterator first
, const_iterator last
);
407 iterator
begin() { return iterator(_start
); }
408 const_iterator
begin() const { return const_iterator(_start
); }
409 const_iterator
cbegin() const { return const_iterator(_start
); }
410 iterator
end() { return iterator(_finish
); }
411 const_iterator
end() const { return const_iterator(_finish
); }
412 const_iterator
cend() const { return const_iterator(_finish
); }
414 T
& front() { return *begin(); }
415 const T
& front() const { return *begin(); }
416 T
& back() { return *--end(); }
417 const T
& back() const { return *--end(); }
427 typedef T value_type
;
428 typedef size_t size_type
;
429 typedef __deque_iterator
<T
, T
*, T
&> iterator
;
430 typedef __deque_iterator
<T
, const T
*, const T
&> const_iterator
;
432 deque() : _start(0), _finish(0), _end_of_storage(0) {}
433 template <typename InputIterator
>
434 deque(InputIterator first
, InputIterator last
);
435 deque(const deque
&other
);
436 deque(deque
&&other
);
439 size_t size() const {
440 return size_t(_finish
- _start
);
443 deque
& operator=(const deque
&other
);
444 deque
& operator=(deque
&&other
);
445 deque
& operator=(std::initializer_list
<T
> ilist
);
447 void assign(size_type count
, const T
&value
);
448 template <typename InputIterator
>
449 void assign(InputIterator first
, InputIterator last
);
450 void assign(std::initializer_list
<T
> ilist
);
454 void push_back(const T
&value
);
455 void push_back(T
&&value
);
456 template<class... Args
>
457 void emplace_back(Args
&&... args
);
460 void push_front(const T
&value
);
461 void push_front(T
&&value
);
462 template<class... Args
>
463 void emplace_front(Args
&&... args
);
466 iterator
insert(const_iterator position
, const value_type
&val
);
467 iterator
insert(const_iterator position
, size_type n
,
468 const value_type
&val
);
469 template <typename InputIterator
>
470 iterator
insert(const_iterator position
, InputIterator first
,
472 iterator
insert(const_iterator position
, value_type
&&val
);
473 iterator
insert(const_iterator position
, initializer_list
<value_type
> il
);
475 template <class... Args
>
476 iterator
emplace(const_iterator position
, Args
&&... args
);
478 iterator
erase(const_iterator position
);
479 iterator
erase(const_iterator first
, const_iterator last
);
481 T
&operator[](size_t n
) {
485 const T
&operator[](size_t n
) const {
489 iterator
begin() { return iterator(_start
); }
490 const_iterator
begin() const { return const_iterator(_start
); }
491 const_iterator
cbegin() const { return const_iterator(_start
); }
492 iterator
end() { return iterator(_finish
); }
493 const_iterator
end() const { return const_iterator(_finish
); }
494 const_iterator
cend() const { return const_iterator(_finish
); }
495 T
& front() { return *begin(); }
496 const T
& front() const { return *begin(); }
497 T
& back() { return *(end() - 1); }
498 const T
& back() const { return *(end() - 1); }
509 typedef T value_type
;
510 typedef size_t size_type
;
511 typedef __fwdl_iterator
<__item
, T
*, T
&> iterator
;
512 typedef __fwdl_iterator
<__item
, const T
*, const T
&> const_iterator
;
514 forward_list() : _start(0) {}
515 template <typename InputIterator
>
516 forward_list(InputIterator first
, InputIterator last
);
517 forward_list(const forward_list
&other
);
518 forward_list(forward_list
&&other
);
521 forward_list
& operator=(const forward_list
&other
);
522 forward_list
& operator=(forward_list
&&other
);
523 forward_list
& operator=(std::initializer_list
<T
> ilist
);
525 void assign(size_type count
, const T
&value
);
526 template <typename InputIterator
>
527 void assign(InputIterator first
, InputIterator last
);
528 void assign(std::initializer_list
<T
> ilist
);
532 void push_front(const T
&value
);
533 void push_front(T
&&value
);
534 template<class... Args
>
535 void emplace_front(Args
&&... args
);
538 iterator
insert_after(const_iterator position
, const value_type
&val
);
539 iterator
insert_after(const_iterator position
, value_type
&&val
);
540 iterator
insert_after(const_iterator position
, size_type n
,
541 const value_type
&val
);
542 template <typename InputIterator
>
543 iterator
insert_after(const_iterator position
, InputIterator first
,
545 iterator
insert_after(const_iterator position
,
546 initializer_list
<value_type
> il
);
548 template <class... Args
>
549 iterator
emplace_after(const_iterator position
, Args
&&... args
);
551 iterator
erase_after(const_iterator position
);
552 iterator
erase_after(const_iterator first
, const_iterator last
);
554 iterator
begin() { return iterator(_start
); }
555 const_iterator
begin() const { return const_iterator(_start
); }
556 const_iterator
cbegin() const { return const_iterator(_start
); }
557 iterator
end() { return iterator(); }
558 const_iterator
end() const { return const_iterator(); }
559 const_iterator
cend() const { return const_iterator(); }
561 T
& front() { return *begin(); }
562 const T
& front() const { return *begin(); }
565 template <typename CharT
>
570 basic_string() : basic_string(Allocator()) {}
571 explicit basic_string(const Allocator
&alloc
);
572 basic_string(size_type count
, CharT ch
,
573 const Allocator
&alloc
= Allocator());
574 basic_string(const basic_string
&other
,
576 const Allocator
&alloc
= Allocator());
577 basic_string(const basic_string
&other
,
578 size_type pos
, size_type count
,
579 const Allocator
&alloc
= Allocator());
580 basic_string(const CharT
*s
, size_type count
,
581 const Allocator
&alloc
= Allocator());
582 basic_string(const CharT
*s
,
583 const Allocator
&alloc
= Allocator());
584 template <class InputIt
>
585 basic_string(InputIt first
, InputIt last
,
586 const Allocator
&alloc
= Allocator());
587 basic_string(const basic_string
&other
);
588 basic_string(const basic_string
&other
,
589 const Allocator
&alloc
);
590 basic_string(basic_string
&&other
);
591 basic_string(basic_string
&&other
,
592 const Allocator
&alloc
);
593 basic_string(std::initializer_list
<CharT
> ilist
,
594 const Allocator
&alloc
= Allocator());
596 basic_string(const T
&t
, size_type pos
, size_type n
,
597 const Allocator
&alloc
= Allocator());
598 // basic_string(std::nullptr_t) = delete;
603 basic_string
&operator=(const basic_string
&str
);
604 basic_string
&operator+=(const basic_string
&str
);
606 const CharT
*c_str() const;
607 const CharT
*data() const;
610 const char *begin() const;
611 const char *end() const;
613 basic_string
&append(size_type count
, CharT ch
);
614 basic_string
&assign(size_type count
, CharT ch
);
615 basic_string
&erase(size_type index
, size_type count
);
616 basic_string
&insert(size_type index
, size_type count
, CharT ch
);
617 basic_string
&replace(size_type pos
, size_type count
, const basic_string
&str
);
619 void push_back(CharT ch
);
620 void reserve(size_type new_cap
);
621 void resize(size_type count
);
622 void shrink_to_fit();
623 void swap(basic_string
&other
);
626 typedef basic_string
<char> string
;
627 typedef basic_string
<wchar_t> wstring
;
628 #if __cplusplus >= 201103L
629 typedef basic_string
<char16_t
> u16string
;
630 typedef basic_string
<char32_t
> u32string
;
636 virtual ~exception() throw();
637 virtual const char *what() const throw() {
642 class bad_alloc
: public exception
{
645 bad_alloc(const bad_alloc
&) throw();
646 bad_alloc
& operator=(const bad_alloc
&) throw();
647 virtual const char* what() const throw() {
653 extern const nothrow_t nothrow
;
655 enum class align_val_t
: size_t {};
657 // libc++'s implementation
659 class initializer_list
664 initializer_list(const _E
* __b
, size_t __s
)
670 typedef _E value_type
;
671 typedef const _E
& reference
;
672 typedef const _E
& const_reference
;
673 typedef size_t size_type
;
675 typedef const _E
* iterator
;
676 typedef const _E
* const_iterator
;
678 initializer_list() : __begin_(0), __size_(0) {}
680 size_t size() const {return __size_
;}
681 const _E
* begin() const {return __begin_
;}
682 const _E
* end() const {return __begin_
+ __size_
;}
685 template <bool, class _Tp
= void> struct enable_if
{};
686 template <class _Tp
> struct enable_if
<true, _Tp
> {typedef _Tp type
;};
688 template <class _Tp
, _Tp __v
>
689 struct integral_constant
691 static const _Tp value
= __v
;
692 typedef _Tp value_type
;
693 typedef integral_constant type
;
695 operator value_type() const {return value
;}
697 value_type
operator ()() const {return value
;}
700 template <class _Tp
, _Tp __v
>
701 const _Tp integral_constant
<_Tp
, __v
>::value
;
703 template <class _Tp
, class _Arg
>
704 struct is_trivially_assignable
705 : integral_constant
<bool, __is_trivially_assignable(_Tp
, _Arg
)>
709 typedef integral_constant
<bool,true> true_type
;
710 typedef integral_constant
<bool,false> false_type
;
712 template <class _Tp
> struct is_const
: public false_type
{};
713 template <class _Tp
> struct is_const
<_Tp
const> : public true_type
{};
715 template <class _Tp
> struct is_reference
: public false_type
{};
716 template <class _Tp
> struct is_reference
<_Tp
&> : public true_type
{};
718 template <class _Tp
, class _Up
> struct is_same
: public false_type
{};
719 template <class _Tp
> struct is_same
<_Tp
, _Tp
> : public true_type
{};
721 template <class _Tp
, bool = is_const
<_Tp
>::value
|| is_reference
<_Tp
>::value
>
722 struct __add_const
{typedef _Tp type
;};
725 struct __add_const
<_Tp
, false> {typedef const _Tp type
;};
727 template <class _Tp
> struct add_const
{typedef typename __add_const
<_Tp
>::type type
;};
729 template <class _Tp
> struct remove_const
{typedef _Tp type
;};
730 template <class _Tp
> struct remove_const
<const _Tp
> {typedef _Tp type
;};
732 template <class _Tp
> struct add_lvalue_reference
{typedef _Tp
& type
;};
734 template <class _Tp
> struct is_trivially_copy_assignable
735 : public is_trivially_assignable
<typename add_lvalue_reference
<_Tp
>::type
,
736 typename add_lvalue_reference
<typename add_const
<_Tp
>::type
>::type
> {};
738 template<class InputIter
, class OutputIter
>
739 OutputIter
__copy(InputIter II
, InputIter IE
, OutputIter OI
) {
746 template <class _Tp
, class _Up
>
750 is_same
<typename remove_const
<_Tp
>::type
, _Up
>::value
&&
751 is_trivially_copy_assignable
<_Up
>::value
,
753 >::type
__copy(_Tp
* __first
, _Tp
* __last
, _Up
* __result
) {
754 size_t __n
= __last
- __first
;
757 memmove(__result
, __first
, __n
* sizeof(_Up
));
759 return __result
+ __n
;
762 template<class InputIter
, class OutputIter
>
763 OutputIter
copy(InputIter II
, InputIter IE
, OutputIter OI
) {
764 return __copy(II
, IE
, OI
);
767 template <class _BidirectionalIterator
, class _OutputIterator
>
770 __copy_backward(_BidirectionalIterator __first
, _BidirectionalIterator __last
,
771 _OutputIterator __result
)
773 while (__first
!= __last
)
774 *--__result
= *--__last
;
778 template <class _Tp
, class _Up
>
782 is_same
<typename remove_const
<_Tp
>::type
, _Up
>::value
&&
783 is_trivially_copy_assignable
<_Up
>::value
,
785 >::type
__copy_backward(_Tp
* __first
, _Tp
* __last
, _Up
* __result
) {
786 size_t __n
= __last
- __first
;
791 memmove(__result
, __first
, __n
* sizeof(_Up
));
796 template<class InputIter
, class OutputIter
>
797 OutputIter
copy_backward(InputIter II
, InputIter IE
, OutputIter OI
) {
798 return __copy_backward(II
, IE
, OI
);
802 template <class BidirectionalIterator
, class Distance
>
803 void __advance(BidirectionalIterator
& it
, Distance n
,
804 std::bidirectional_iterator_tag
)
805 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 2
807 if (n
>= 0) while(n
-- > 0) ++it
; else while (n
++<0) --it
;
813 template <class RandomAccessIterator
, class Distance
>
814 void __advance(RandomAccessIterator
& it
, Distance n
,
815 std::random_access_iterator_tag
)
816 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 2
826 template <class InputIterator
, class Distance
>
827 void advance(InputIterator
& it
, Distance n
)
828 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 1
830 __advance(it
, n
, typename
InputIterator::iterator_category());
836 template <class BidirectionalIterator
>
837 BidirectionalIterator
838 prev(BidirectionalIterator it
,
839 typename iterator_traits
<BidirectionalIterator
>::difference_type n
=
841 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 0
850 template <class ForwardIterator
>
852 next(ForwardIterator it
,
853 typename iterator_traits
<ForwardIterator
>::difference_type n
=
855 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 0
864 template <class InputIt
, class T
>
865 InputIt
find(InputIt first
, InputIt last
, const T
& value
);
867 template <class ExecutionPolicy
, class ForwardIt
, class T
>
868 ForwardIt
find(ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
871 template <class InputIt
, class UnaryPredicate
>
872 InputIt
find_if (InputIt first
, InputIt last
, UnaryPredicate p
);
874 template <class ExecutionPolicy
, class ForwardIt
, class UnaryPredicate
>
875 ForwardIt
find_if (ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
878 template <class InputIt
, class UnaryPredicate
>
879 InputIt
find_if_not (InputIt first
, InputIt last
, UnaryPredicate q
);
881 template <class ExecutionPolicy
, class ForwardIt
, class UnaryPredicate
>
882 ForwardIt
find_if_not (ExecutionPolicy
&& policy
, ForwardIt first
,
883 ForwardIt last
, UnaryPredicate q
);
885 template <class InputIt
, class ForwardIt
>
886 InputIt
find_first_of(InputIt first
, InputIt last
,
887 ForwardIt s_first
, ForwardIt s_last
);
889 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
>
890 ForwardIt1
find_first_of (ExecutionPolicy
&& policy
,
891 ForwardIt1 first
, ForwardIt1 last
,
892 ForwardIt2 s_first
, ForwardIt2 s_last
);
894 template <class InputIt
, class ForwardIt
, class BinaryPredicate
>
895 InputIt
find_first_of (InputIt first
, InputIt last
,
896 ForwardIt s_first
, ForwardIt s_last
,
899 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
,
900 class BinaryPredicate
>
901 ForwardIt1
find_first_of (ExecutionPolicy
&& policy
,
902 ForwardIt1 first
, ForwardIt1 last
,
903 ForwardIt2 s_first
, ForwardIt2 s_last
,
906 template <class InputIt
, class ForwardIt
>
907 InputIt
find_end(InputIt first
, InputIt last
,
908 ForwardIt s_first
, ForwardIt s_last
);
910 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
>
911 ForwardIt1
find_end (ExecutionPolicy
&& policy
,
912 ForwardIt1 first
, ForwardIt1 last
,
913 ForwardIt2 s_first
, ForwardIt2 s_last
);
915 template <class InputIt
, class ForwardIt
, class BinaryPredicate
>
916 InputIt
find_end (InputIt first
, InputIt last
,
917 ForwardIt s_first
, ForwardIt s_last
,
920 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
,
921 class BinaryPredicate
>
922 ForwardIt1
find_end (ExecutionPolicy
&& policy
,
923 ForwardIt1 first
, ForwardIt1 last
,
924 ForwardIt2 s_first
, ForwardIt2 s_last
,
927 template <class ForwardIt
, class T
>
928 ForwardIt
lower_bound (ForwardIt first
, ForwardIt last
, const T
& value
);
930 template <class ForwardIt
, class T
, class Compare
>
931 ForwardIt
lower_bound (ForwardIt first
, ForwardIt last
, const T
& value
,
934 template <class ForwardIt
, class T
>
935 ForwardIt
upper_bound (ForwardIt first
, ForwardIt last
, const T
& value
);
937 template <class ForwardIt
, class T
, class Compare
>
938 ForwardIt
upper_bound (ForwardIt first
, ForwardIt last
, const T
& value
,
941 template <class ForwardIt1
, class ForwardIt2
>
942 ForwardIt1
search (ForwardIt1 first
, ForwardIt1 last
,
943 ForwardIt2 s_first
, ForwardIt2 s_last
);
945 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
>
946 ForwardIt1
search (ExecutionPolicy
&& policy
,
947 ForwardIt1 first
, ForwardIt1 last
,
948 ForwardIt2 s_first
, ForwardIt2 s_last
);
950 template <class ForwardIt1
, class ForwardIt2
, class BinaryPredicate
>
951 ForwardIt1
search (ForwardIt1 first
, ForwardIt1 last
,
952 ForwardIt2 s_first
, ForwardIt2 s_last
, BinaryPredicate p
);
954 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
,
955 class BinaryPredicate
>
956 ForwardIt1
search (ExecutionPolicy
&& policy
,
957 ForwardIt1 first
, ForwardIt1 last
,
958 ForwardIt2 s_first
, ForwardIt2 s_last
, BinaryPredicate p
);
960 template <class ForwardIt
, class Searcher
>
961 ForwardIt
search (ForwardIt first
, ForwardIt last
, const Searcher
& searcher
);
963 template <class ForwardIt
, class Size
, class T
>
964 ForwardIt
search_n (ForwardIt first
, ForwardIt last
, Size count
,
967 template <class ExecutionPolicy
, class ForwardIt
, class Size
, class T
>
968 ForwardIt
search_n (ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
969 Size count
, const T
& value
);
971 template <class ForwardIt
, class Size
, class T
, class BinaryPredicate
>
972 ForwardIt
search_n (ForwardIt first
, ForwardIt last
, Size count
,
973 const T
& value
, BinaryPredicate p
);
975 template <class ExecutionPolicy
, class ForwardIt
, class Size
, class T
,
976 class BinaryPredicate
>
977 ForwardIt
search_n (ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
978 Size count
, const T
& value
, BinaryPredicate p
);
980 template <class InputIterator
, class OutputIterator
>
981 OutputIterator
copy(InputIterator first
, InputIterator last
,
982 OutputIterator result
);
986 #if __cplusplus >= 201103L
988 template <typename T
> // TODO: Implement the stub for deleter.
991 unique_ptr() noexcept
{}
992 unique_ptr(T
*) noexcept
{}
993 unique_ptr(const unique_ptr
&) noexcept
= delete;
994 unique_ptr(unique_ptr
&&) noexcept
;
996 T
*get() const noexcept
;
997 T
*release() noexcept
;
998 void reset(T
*p
= nullptr) noexcept
;
999 void swap(unique_ptr
<T
> &p
) noexcept
;
1001 typename
std::add_lvalue_reference
<T
>::type
operator*() const;
1002 T
*operator->() const noexcept
;
1003 operator bool() const noexcept
;
1004 unique_ptr
<T
> &operator=(unique_ptr
<T
> &&p
) noexcept
;
1005 unique_ptr
<T
> &operator=(nullptr_t
) noexcept
;
1008 // TODO :: Once the deleter parameter is added update with additional template parameter.
1009 template <typename T
>
1010 void swap(unique_ptr
<T
> &x
, unique_ptr
<T
> &y
) noexcept
{
1014 template <typename T1
, typename T2
>
1015 bool operator==(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1017 template <typename T1
, typename T2
>
1018 bool operator!=(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1020 template <typename T1
, typename T2
>
1021 bool operator<(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1023 template <typename T1
, typename T2
>
1024 bool operator>(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1026 template <typename T1
, typename T2
>
1027 bool operator<=(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1029 template <typename T1
, typename T2
>
1030 bool operator>=(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1032 template <typename T
>
1033 bool operator==(const unique_ptr
<T
> &x
, nullptr_t y
);
1035 template <typename T
>
1036 bool operator!=(const unique_ptr
<T
> &x
, nullptr_t y
);
1038 template <typename T
>
1039 bool operator<(const unique_ptr
<T
> &x
, nullptr_t y
);
1041 template <typename T
>
1042 bool operator>(const unique_ptr
<T
> &x
, nullptr_t y
);
1044 template <typename T
>
1045 bool operator<=(const unique_ptr
<T
> &x
, nullptr_t y
);
1047 template <typename T
>
1048 bool operator>=(const unique_ptr
<T
> &x
, nullptr_t y
);
1050 template <typename T
>
1051 bool operator==(nullptr_t x
, const unique_ptr
<T
> &y
);
1053 template <typename T
>
1054 bool operator!=(nullptr_t x
, const unique_ptr
<T
> &y
);
1056 template <typename T
>
1057 bool operator>(nullptr_t x
, const unique_ptr
<T
> &y
);
1059 template <typename T
>
1060 bool operator<(nullptr_t x
, const unique_ptr
<T
> &y
);
1062 template <typename T
>
1063 bool operator>=(nullptr_t x
, const unique_ptr
<T
> &y
);
1065 template <typename T
>
1066 bool operator<=(nullptr_t x
, const unique_ptr
<T
> &y
);
1068 template <class T
, class... Args
>
1069 unique_ptr
<T
> make_unique(Args
&&...args
);
1071 #if __cplusplus >= 202002L
1074 unique_ptr
<T
> make_unique_for_overwrite();
1082 template <class CharT
>
1083 class basic_ostream
;
1085 using ostream
= basic_ostream
<char>;
1087 extern std::ostream cout
;
1089 ostream
&operator<<(ostream
&, const string
&);
1091 #if __cplusplus >= 202002L
1093 ostream
&operator<<(ostream
&, const std::unique_ptr
<T
> &);
1097 #ifdef TEST_INLINABLE_ALLOCATORS
1099 void *malloc(size_t);
1102 void* operator new(std::size_t size
, const std::nothrow_t
&) throw() { return std::malloc(size
); }
1103 void* operator new[](std::size_t size
, const std::nothrow_t
&) throw() { return std::malloc(size
); }
1104 void operator delete(void* ptr
, const std::nothrow_t
&) throw() { std::free(ptr
); }
1105 void operator delete[](void* ptr
, const std::nothrow_t
&) throw() { std::free(ptr
); }
1107 // C++20 standard draft 17.6.1, from "Header <new> synopsis", but with throw()
1108 // instead of noexcept:
1110 void *operator new(std::size_t size
);
1111 void *operator new(std::size_t size
, std::align_val_t alignment
);
1112 void *operator new(std::size_t size
, const std::nothrow_t
&) throw();
1113 void *operator new(std::size_t size
, std::align_val_t alignment
,
1114 const std::nothrow_t
&) throw();
1115 void operator delete(void *ptr
) throw();
1116 void operator delete(void *ptr
, std::size_t size
) throw();
1117 void operator delete(void *ptr
, std::align_val_t alignment
) throw();
1118 void operator delete(void *ptr
, std::size_t size
, std::align_val_t alignment
) throw();
1119 void operator delete(void *ptr
, const std::nothrow_t
&)throw();
1120 void operator delete(void *ptr
, std::align_val_t alignment
,
1121 const std::nothrow_t
&)throw();
1122 void *operator new[](std::size_t size
);
1123 void *operator new[](std::size_t size
, std::align_val_t alignment
);
1124 void *operator new[](std::size_t size
, const std::nothrow_t
&) throw();
1125 void *operator new[](std::size_t size
, std::align_val_t alignment
,
1126 const std::nothrow_t
&) throw();
1127 void operator delete[](void *ptr
) throw();
1128 void operator delete[](void *ptr
, std::size_t size
) throw();
1129 void operator delete[](void *ptr
, std::align_val_t alignment
) throw();
1130 void operator delete[](void *ptr
, std::size_t size
, std::align_val_t alignment
) throw();
1131 void operator delete[](void *ptr
, const std::nothrow_t
&) throw();
1132 void operator delete[](void *ptr
, std::align_val_t alignment
,
1133 const std::nothrow_t
&) throw();
1136 void* operator new (std::size_t size
, void* ptr
) throw() { return ptr
; };
1137 void* operator new[] (std::size_t size
, void* ptr
) throw() { return ptr
; };
1138 void operator delete (void* ptr
, void*) throw() {};
1139 void operator delete[] (void* ptr
, void*) throw() {};
1141 namespace __cxxabiv1
{
1143 extern char *__cxa_demangle(const char *mangled_name
,
1144 char *output_buffer
,
1148 namespace abi
= __cxxabiv1
;
1151 template<class ForwardIt
>
1152 bool is_sorted(ForwardIt first
, ForwardIt last
);
1154 template <class RandomIt
>
1155 void nth_element(RandomIt first
, RandomIt nth
, RandomIt last
);
1157 template<class RandomIt
>
1158 void partial_sort(RandomIt first
, RandomIt middle
, RandomIt last
);
1160 template<class RandomIt
>
1161 void sort (RandomIt first
, RandomIt last
);
1163 template<class RandomIt
>
1164 void stable_sort(RandomIt first
, RandomIt last
);
1166 template<class BidirIt
, class UnaryPredicate
>
1167 BidirIt
partition(BidirIt first
, BidirIt last
, UnaryPredicate p
);
1169 template<class BidirIt
, class UnaryPredicate
>
1170 BidirIt
stable_partition(BidirIt first
, BidirIt last
, UnaryPredicate p
);
1175 template< class T
= void >
1181 template< class Key
>
1186 class Compare
= std::less
<Key
>,
1187 class Alloc
= std::allocator
<Key
>
1190 set(initializer_list
<Key
> __list
) {}
1194 iterator(Key
*key
): ptr(key
) {}
1195 iterator
& operator++() { ++ptr
; return *this; }
1196 bool operator!=(const iterator
&other
) const { return ptr
!= other
.ptr
; }
1197 const Key
&operator*() const { return *ptr
; }
1204 iterator
begin() const { return iterator(val
); }
1205 iterator
end() const { return iterator(val
+ 1); }
1210 class Hash
= std::hash
<Key
>,
1211 class Compare
= std::less
<Key
>,
1212 class Alloc
= std::allocator
<Key
>
1213 > class unordered_set
{
1215 unordered_set(initializer_list
<Key
> __list
) {}
1219 iterator(Key
*key
): ptr(key
) {}
1220 iterator
& operator++() { ++ptr
; return *this; }
1221 bool operator!=(const iterator
&other
) const { return ptr
!= other
.ptr
; }
1222 const Key
&operator*() const { return *ptr
; }
1229 iterator
begin() const { return iterator(val
); }
1230 iterator
end() const { return iterator(val
+ 1); }
1233 namespace execution
{
1234 class sequenced_policy
{};
1237 template <class T
= void> struct equal_to
{};
1239 template <class ForwardIt
, class BinaryPredicate
= std::equal_to
<> >
1240 class default_searcher
{
1242 default_searcher (ForwardIt pat_first
,
1244 BinaryPredicate pred
= BinaryPredicate());
1245 template <class ForwardIt2
>
1246 std::pair
<ForwardIt2
, ForwardIt2
>
1247 operator()( ForwardIt2 first
, ForwardIt2 last
) const;
1250 template <typename
> class packaged_task
;
1251 template <typename Ret
, typename
... Args
> class packaged_task
<Ret(Args
...)> {
1252 // TODO: Add some actual implementation.