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 template<class T2
, class T1
>
254 T2
& get(pair
<T1
, T2
>& p
) ;
255 template<class T1
, class T2
>
256 T1
& get(const pair
<T1
, T2
>& p
) ;
258 typedef __typeof__(sizeof(int)) size_t;
260 template <class T
> class initializer_list
;
262 template< class T
> struct remove_reference
{typedef T type
;};
263 template< class T
> struct remove_reference
<T
&> {typedef T type
;};
264 template< class T
> struct remove_reference
<T
&&> {typedef T type
;};
266 template<typename T
> typename remove_reference
<T
>::type
&& move(T
&& a
);
267 template <typename T
> T
*__addressof(T
&x
);
268 template <typename T
> T
*addressof(T
&x
);
269 template <typename T
> const T
& as_const(T
& x
);
270 template <typename T
> T
&& forward(T
&& x
);
271 // FIXME: Declare forward_like
272 // FIXME: Declare move_if_noexcept
275 using remove_reference_t
= typename remove_reference
<T
>::type
;
278 void swap(T
&a
, T
&b
) {
291 typedef T value_type
;
292 typedef size_t size_type
;
293 typedef __vector_iterator
<T
, T
*, T
&> iterator
;
294 typedef __vector_iterator
<T
, const T
*, const T
&> const_iterator
;
296 vector() : _start(0), _finish(0), _end_of_storage(0) {}
297 template <typename InputIterator
>
298 vector(InputIterator first
, InputIterator last
);
299 vector(const vector
&other
);
300 vector(vector
&&other
);
303 size_t size() const {
304 return size_t(_finish
- _start
);
307 vector
& operator=(const vector
&other
);
308 vector
& operator=(vector
&&other
);
309 vector
& operator=(std::initializer_list
<T
> ilist
);
311 void assign(size_type count
, const T
&value
);
312 template <typename InputIterator
>
313 void assign(InputIterator first
, InputIterator last
);
314 void assign(std::initializer_list
<T
> ilist
);
318 void push_back(const T
&value
);
319 void push_back(T
&&value
);
320 template<class... Args
>
321 void emplace_back(Args
&&... args
);
324 iterator
insert(const_iterator position
, const value_type
&val
);
325 iterator
insert(const_iterator position
, size_type n
,
326 const value_type
&val
);
327 template <typename InputIterator
>
328 iterator
insert(const_iterator position
, InputIterator first
,
330 iterator
insert(const_iterator position
, value_type
&&val
);
331 iterator
insert(const_iterator position
, initializer_list
<value_type
> il
);
333 template <class... Args
>
334 iterator
emplace(const_iterator position
, Args
&&... args
);
336 iterator
erase(const_iterator position
);
337 iterator
erase(const_iterator first
, const_iterator last
);
339 T
&operator[](size_t n
) {
343 const T
&operator[](size_t n
) const {
347 iterator
begin() { return iterator(_start
); }
348 const_iterator
begin() const { return const_iterator(_start
); }
349 const_iterator
cbegin() const { return const_iterator(_start
); }
350 iterator
end() { return iterator(_finish
); }
351 const_iterator
end() const { return const_iterator(_finish
); }
352 const_iterator
cend() const { return const_iterator(_finish
); }
353 T
& front() { return *begin(); }
354 const T
& front() const { return *begin(); }
355 T
& back() { return *(end() - 1); }
356 const T
& back() const { return *(end() - 1); }
367 typedef T value_type
;
368 typedef size_t size_type
;
369 typedef __list_iterator
<__item
, T
*, T
&> iterator
;
370 typedef __list_iterator
<__item
, const T
*, const T
&> const_iterator
;
372 list() : _start(0), _finish(0) {}
373 template <typename InputIterator
>
374 list(InputIterator first
, InputIterator last
);
375 list(const list
&other
);
379 list
& operator=(const list
&other
);
380 list
& operator=(list
&&other
);
381 list
& operator=(std::initializer_list
<T
> ilist
);
383 void assign(size_type count
, const T
&value
);
384 template <typename InputIterator
>
385 void assign(InputIterator first
, InputIterator last
);
386 void assign(std::initializer_list
<T
> ilist
);
390 void push_back(const T
&value
);
391 void push_back(T
&&value
);
392 template<class... Args
>
393 void emplace_back(Args
&&... args
);
396 void push_front(const T
&value
);
397 void push_front(T
&&value
);
398 template<class... Args
>
399 void emplace_front(Args
&&... args
);
402 iterator
insert(const_iterator position
, const value_type
&val
);
403 iterator
insert(const_iterator position
, size_type n
,
404 const value_type
&val
);
405 template <typename InputIterator
>
406 iterator
insert(const_iterator position
, InputIterator first
,
408 iterator
insert(const_iterator position
, value_type
&&val
);
409 iterator
insert(const_iterator position
, initializer_list
<value_type
> il
);
411 template <class... Args
>
412 iterator
emplace(const_iterator position
, Args
&&... args
);
414 iterator
erase(const_iterator position
);
415 iterator
erase(const_iterator first
, const_iterator last
);
417 iterator
begin() { return iterator(_start
); }
418 const_iterator
begin() const { return const_iterator(_start
); }
419 const_iterator
cbegin() const { return const_iterator(_start
); }
420 iterator
end() { return iterator(_finish
); }
421 const_iterator
end() const { return const_iterator(_finish
); }
422 const_iterator
cend() const { return const_iterator(_finish
); }
424 T
& front() { return *begin(); }
425 const T
& front() const { return *begin(); }
426 T
& back() { return *--end(); }
427 const T
& back() const { return *--end(); }
437 typedef T value_type
;
438 typedef size_t size_type
;
439 typedef __deque_iterator
<T
, T
*, T
&> iterator
;
440 typedef __deque_iterator
<T
, const T
*, const T
&> const_iterator
;
442 deque() : _start(0), _finish(0), _end_of_storage(0) {}
443 template <typename InputIterator
>
444 deque(InputIterator first
, InputIterator last
);
445 deque(const deque
&other
);
446 deque(deque
&&other
);
449 size_t size() const {
450 return size_t(_finish
- _start
);
453 deque
& operator=(const deque
&other
);
454 deque
& operator=(deque
&&other
);
455 deque
& operator=(std::initializer_list
<T
> ilist
);
457 void assign(size_type count
, const T
&value
);
458 template <typename InputIterator
>
459 void assign(InputIterator first
, InputIterator last
);
460 void assign(std::initializer_list
<T
> ilist
);
464 void push_back(const T
&value
);
465 void push_back(T
&&value
);
466 template<class... Args
>
467 void emplace_back(Args
&&... args
);
470 void push_front(const T
&value
);
471 void push_front(T
&&value
);
472 template<class... Args
>
473 void emplace_front(Args
&&... args
);
476 iterator
insert(const_iterator position
, const value_type
&val
);
477 iterator
insert(const_iterator position
, size_type n
,
478 const value_type
&val
);
479 template <typename InputIterator
>
480 iterator
insert(const_iterator position
, InputIterator first
,
482 iterator
insert(const_iterator position
, value_type
&&val
);
483 iterator
insert(const_iterator position
, initializer_list
<value_type
> il
);
485 template <class... Args
>
486 iterator
emplace(const_iterator position
, Args
&&... args
);
488 iterator
erase(const_iterator position
);
489 iterator
erase(const_iterator first
, const_iterator last
);
491 T
&operator[](size_t n
) {
495 const T
&operator[](size_t n
) const {
499 iterator
begin() { return iterator(_start
); }
500 const_iterator
begin() const { return const_iterator(_start
); }
501 const_iterator
cbegin() const { return const_iterator(_start
); }
502 iterator
end() { return iterator(_finish
); }
503 const_iterator
end() const { return const_iterator(_finish
); }
504 const_iterator
cend() const { return const_iterator(_finish
); }
505 T
& front() { return *begin(); }
506 const T
& front() const { return *begin(); }
507 T
& back() { return *(end() - 1); }
508 const T
& back() const { return *(end() - 1); }
519 typedef T value_type
;
520 typedef size_t size_type
;
521 typedef __fwdl_iterator
<__item
, T
*, T
&> iterator
;
522 typedef __fwdl_iterator
<__item
, const T
*, const T
&> const_iterator
;
524 forward_list() : _start(0) {}
525 template <typename InputIterator
>
526 forward_list(InputIterator first
, InputIterator last
);
527 forward_list(const forward_list
&other
);
528 forward_list(forward_list
&&other
);
531 forward_list
& operator=(const forward_list
&other
);
532 forward_list
& operator=(forward_list
&&other
);
533 forward_list
& operator=(std::initializer_list
<T
> ilist
);
535 void assign(size_type count
, const T
&value
);
536 template <typename InputIterator
>
537 void assign(InputIterator first
, InputIterator last
);
538 void assign(std::initializer_list
<T
> ilist
);
542 void push_front(const T
&value
);
543 void push_front(T
&&value
);
544 template<class... Args
>
545 void emplace_front(Args
&&... args
);
548 iterator
insert_after(const_iterator position
, const value_type
&val
);
549 iterator
insert_after(const_iterator position
, value_type
&&val
);
550 iterator
insert_after(const_iterator position
, size_type n
,
551 const value_type
&val
);
552 template <typename InputIterator
>
553 iterator
insert_after(const_iterator position
, InputIterator first
,
555 iterator
insert_after(const_iterator position
,
556 initializer_list
<value_type
> il
);
558 template <class... Args
>
559 iterator
emplace_after(const_iterator position
, Args
&&... args
);
561 iterator
erase_after(const_iterator position
);
562 iterator
erase_after(const_iterator first
, const_iterator last
);
564 iterator
begin() { return iterator(_start
); }
565 const_iterator
begin() const { return const_iterator(_start
); }
566 const_iterator
cbegin() const { return const_iterator(_start
); }
567 iterator
end() { return iterator(); }
568 const_iterator
end() const { return const_iterator(); }
569 const_iterator
cend() const { return const_iterator(); }
571 T
& front() { return *begin(); }
572 const T
& front() const { return *begin(); }
575 template <typename CharT
>
580 basic_string() : basic_string(Allocator()) {}
581 explicit basic_string(const Allocator
&alloc
);
582 basic_string(size_type count
, CharT ch
,
583 const Allocator
&alloc
= Allocator());
584 basic_string(const basic_string
&other
,
586 const Allocator
&alloc
= Allocator());
587 basic_string(const basic_string
&other
,
588 size_type pos
, size_type count
,
589 const Allocator
&alloc
= Allocator());
590 basic_string(const CharT
*s
, size_type count
,
591 const Allocator
&alloc
= Allocator());
592 basic_string(const CharT
*s
,
593 const Allocator
&alloc
= Allocator());
594 template <class InputIt
>
595 basic_string(InputIt first
, InputIt last
,
596 const Allocator
&alloc
= Allocator());
597 basic_string(const basic_string
&other
);
598 basic_string(const basic_string
&other
,
599 const Allocator
&alloc
);
600 basic_string(basic_string
&&other
);
601 basic_string(basic_string
&&other
,
602 const Allocator
&alloc
);
603 basic_string(std::initializer_list
<CharT
> ilist
,
604 const Allocator
&alloc
= Allocator());
606 basic_string(const T
&t
, size_type pos
, size_type n
,
607 const Allocator
&alloc
= Allocator());
608 // basic_string(std::nullptr_t) = delete;
613 basic_string
&operator=(const basic_string
&str
);
614 basic_string
&operator+=(const basic_string
&str
);
616 const CharT
*c_str() const;
617 const CharT
*data() const;
620 const char *begin() const;
621 const char *end() const;
623 basic_string
&append(size_type count
, CharT ch
);
624 basic_string
&assign(size_type count
, CharT ch
);
625 basic_string
&erase(size_type index
, size_type count
);
626 basic_string
&insert(size_type index
, size_type count
, CharT ch
);
627 basic_string
&replace(size_type pos
, size_type count
, const basic_string
&str
);
629 void push_back(CharT ch
);
630 void reserve(size_type new_cap
);
631 void resize(size_type count
);
632 void shrink_to_fit();
633 void swap(basic_string
&other
);
636 typedef basic_string
<char> string
;
637 typedef basic_string
<wchar_t> wstring
;
638 #if __cplusplus >= 201103L
639 typedef basic_string
<char16_t
> u16string
;
640 typedef basic_string
<char32_t
> u32string
;
646 virtual ~exception() throw();
647 virtual const char *what() const throw() {
652 class bad_alloc
: public exception
{
655 bad_alloc(const bad_alloc
&) throw();
656 bad_alloc
& operator=(const bad_alloc
&) throw();
657 virtual const char* what() const throw() {
663 extern const nothrow_t nothrow
;
665 enum class align_val_t
: size_t {};
667 // libc++'s implementation
669 class initializer_list
674 initializer_list(const _E
* __b
, size_t __s
)
680 typedef _E value_type
;
681 typedef const _E
& reference
;
682 typedef const _E
& const_reference
;
683 typedef size_t size_type
;
685 typedef const _E
* iterator
;
686 typedef const _E
* const_iterator
;
688 initializer_list() : __begin_(0), __size_(0) {}
690 size_t size() const {return __size_
;}
691 const _E
* begin() const {return __begin_
;}
692 const _E
* end() const {return __begin_
+ __size_
;}
695 template <bool, class _Tp
= void> struct enable_if
{};
696 template <class _Tp
> struct enable_if
<true, _Tp
> {typedef _Tp type
;};
698 template <class _Tp
, _Tp __v
>
699 struct integral_constant
701 static const _Tp value
= __v
;
702 typedef _Tp value_type
;
703 typedef integral_constant type
;
705 operator value_type() const {return value
;}
707 value_type
operator ()() const {return value
;}
710 template <class _Tp
, _Tp __v
>
711 const _Tp integral_constant
<_Tp
, __v
>::value
;
713 template <class _Tp
, class _Arg
>
714 struct is_trivially_assignable
715 : integral_constant
<bool, __is_trivially_assignable(_Tp
, _Arg
)>
719 typedef integral_constant
<bool,true> true_type
;
720 typedef integral_constant
<bool,false> false_type
;
722 template <class _Tp
> struct is_const
: public false_type
{};
723 template <class _Tp
> struct is_const
<_Tp
const> : public true_type
{};
725 template <class _Tp
> struct is_reference
: public false_type
{};
726 template <class _Tp
> struct is_reference
<_Tp
&> : public true_type
{};
728 template <class _Tp
, class _Up
> struct is_same
: public false_type
{};
729 template <class _Tp
> struct is_same
<_Tp
, _Tp
> : public true_type
{};
731 #if __cplusplus >= 201703L
732 template< class T
, class U
>
733 inline constexpr bool is_same_v
= is_same
<T
, U
>::value
;
736 template <class _Tp
, bool = is_const
<_Tp
>::value
|| is_reference
<_Tp
>::value
>
737 struct __add_const
{typedef _Tp type
;};
740 struct __add_const
<_Tp
, false> {typedef const _Tp type
;};
742 template <class _Tp
> struct add_const
{typedef typename __add_const
<_Tp
>::type type
;};
744 template <class _Tp
> struct remove_const
{typedef _Tp type
;};
745 template <class _Tp
> struct remove_const
<const _Tp
> {typedef _Tp type
;};
748 using remove_const_t
= typename remove_const
<T
>::type
;
750 template <class _Tp
> struct add_lvalue_reference
{typedef _Tp
& type
;};
752 template <class _Tp
> struct is_trivially_copy_assignable
753 : public is_trivially_assignable
<typename add_lvalue_reference
<_Tp
>::type
,
754 typename add_lvalue_reference
<typename add_const
<_Tp
>::type
>::type
> {};
756 template<class InputIter
, class OutputIter
>
757 OutputIter
__copy(InputIter II
, InputIter IE
, OutputIter OI
) {
759 *OI
++ = *II
++; // #system_header_simulator_cxx_std_copy_impl_loop
764 template <class _Tp
, class _Up
>
768 is_same
<typename remove_const
<_Tp
>::type
, _Up
>::value
&&
769 is_trivially_copy_assignable
<_Up
>::value
,
771 >::type
__copy(_Tp
* __first
, _Tp
* __last
, _Up
* __result
) {
772 size_t __n
= __last
- __first
;
775 memmove(__result
, __first
, __n
* sizeof(_Up
));
777 return __result
+ __n
;
780 template<class InputIter
, class OutputIter
>
781 OutputIter
copy(InputIter II
, InputIter IE
, OutputIter OI
) {
782 return __copy(II
, IE
, OI
);
785 template <class _BidirectionalIterator
, class _OutputIterator
>
788 __copy_backward(_BidirectionalIterator __first
, _BidirectionalIterator __last
,
789 _OutputIterator __result
)
791 while (__first
!= __last
)
792 *--__result
= *--__last
;
796 template <class _Tp
, class _Up
>
800 is_same
<typename remove_const
<_Tp
>::type
, _Up
>::value
&&
801 is_trivially_copy_assignable
<_Up
>::value
,
803 >::type
__copy_backward(_Tp
* __first
, _Tp
* __last
, _Up
* __result
) {
804 size_t __n
= __last
- __first
;
809 memmove(__result
, __first
, __n
* sizeof(_Up
));
814 template< bool B
, class T
= void >
815 using enable_if_t
= typename enable_if
<B
,T
>::type
;
817 template<class InputIter
, class OutputIter
>
818 OutputIter
copy_backward(InputIter II
, InputIter IE
, OutputIter OI
) {
819 return __copy_backward(II
, IE
, OI
);
823 template <class BidirectionalIterator
, class Distance
>
824 void __advance(BidirectionalIterator
& it
, Distance n
,
825 std::bidirectional_iterator_tag
)
826 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 2
828 if (n
>= 0) while(n
-- > 0) ++it
; else while (n
++<0) --it
;
834 template <class RandomAccessIterator
, class Distance
>
835 void __advance(RandomAccessIterator
& it
, Distance n
,
836 std::random_access_iterator_tag
)
837 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 2
847 template <class InputIterator
, class Distance
>
848 void advance(InputIterator
& it
, Distance n
)
849 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 1
851 __advance(it
, n
, typename
InputIterator::iterator_category());
857 template <class BidirectionalIterator
>
858 BidirectionalIterator
859 prev(BidirectionalIterator it
,
860 typename iterator_traits
<BidirectionalIterator
>::difference_type n
=
862 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 0
871 template <class ForwardIterator
>
873 next(ForwardIterator it
,
874 typename iterator_traits
<ForwardIterator
>::difference_type n
=
876 #if !defined(STD_ADVANCE_INLINE_LEVEL) || STD_ADVANCE_INLINE_LEVEL > 0
885 template <class InputIt
, class T
>
886 InputIt
find(InputIt first
, InputIt last
, const T
& value
);
888 template <class ExecutionPolicy
, class ForwardIt
, class T
>
889 ForwardIt
find(ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
892 template <class InputIt
, class UnaryPredicate
>
893 InputIt
find_if (InputIt first
, InputIt last
, UnaryPredicate p
);
895 template <class ExecutionPolicy
, class ForwardIt
, class UnaryPredicate
>
896 ForwardIt
find_if (ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
899 template <class InputIt
, class UnaryPredicate
>
900 InputIt
find_if_not (InputIt first
, InputIt last
, UnaryPredicate q
);
902 template <class ExecutionPolicy
, class ForwardIt
, class UnaryPredicate
>
903 ForwardIt
find_if_not (ExecutionPolicy
&& policy
, ForwardIt first
,
904 ForwardIt last
, UnaryPredicate q
);
906 template <class InputIt
, class ForwardIt
>
907 InputIt
find_first_of(InputIt first
, InputIt last
,
908 ForwardIt s_first
, ForwardIt s_last
);
910 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
>
911 ForwardIt1
find_first_of (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_first_of (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_first_of (ExecutionPolicy
&& policy
,
923 ForwardIt1 first
, ForwardIt1 last
,
924 ForwardIt2 s_first
, ForwardIt2 s_last
,
927 template <class InputIt
, class ForwardIt
>
928 InputIt
find_end(InputIt first
, InputIt last
,
929 ForwardIt s_first
, ForwardIt s_last
);
931 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
>
932 ForwardIt1
find_end (ExecutionPolicy
&& policy
,
933 ForwardIt1 first
, ForwardIt1 last
,
934 ForwardIt2 s_first
, ForwardIt2 s_last
);
936 template <class InputIt
, class ForwardIt
, class BinaryPredicate
>
937 InputIt
find_end (InputIt first
, InputIt last
,
938 ForwardIt s_first
, ForwardIt s_last
,
941 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
,
942 class BinaryPredicate
>
943 ForwardIt1
find_end (ExecutionPolicy
&& policy
,
944 ForwardIt1 first
, ForwardIt1 last
,
945 ForwardIt2 s_first
, ForwardIt2 s_last
,
948 template <class ForwardIt
, class T
>
949 ForwardIt
lower_bound (ForwardIt first
, ForwardIt last
, const T
& value
);
951 template <class ForwardIt
, class T
, class Compare
>
952 ForwardIt
lower_bound (ForwardIt first
, ForwardIt last
, const T
& value
,
955 template <class ForwardIt
, class T
>
956 ForwardIt
upper_bound (ForwardIt first
, ForwardIt last
, const T
& value
);
958 template <class ForwardIt
, class T
, class Compare
>
959 ForwardIt
upper_bound (ForwardIt first
, ForwardIt last
, const T
& value
,
962 template <class ForwardIt1
, class ForwardIt2
>
963 ForwardIt1
search (ForwardIt1 first
, ForwardIt1 last
,
964 ForwardIt2 s_first
, ForwardIt2 s_last
);
966 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
>
967 ForwardIt1
search (ExecutionPolicy
&& policy
,
968 ForwardIt1 first
, ForwardIt1 last
,
969 ForwardIt2 s_first
, ForwardIt2 s_last
);
971 template <class ForwardIt1
, class ForwardIt2
, class BinaryPredicate
>
972 ForwardIt1
search (ForwardIt1 first
, ForwardIt1 last
,
973 ForwardIt2 s_first
, ForwardIt2 s_last
, BinaryPredicate p
);
975 template <class ExecutionPolicy
, class ForwardIt1
, class ForwardIt2
,
976 class BinaryPredicate
>
977 ForwardIt1
search (ExecutionPolicy
&& policy
,
978 ForwardIt1 first
, ForwardIt1 last
,
979 ForwardIt2 s_first
, ForwardIt2 s_last
, BinaryPredicate p
);
981 template <class ForwardIt
, class Searcher
>
982 ForwardIt
search (ForwardIt first
, ForwardIt last
, const Searcher
& searcher
);
984 template <class ForwardIt
, class Size
, class T
>
985 ForwardIt
search_n (ForwardIt first
, ForwardIt last
, Size count
,
988 template <class ExecutionPolicy
, class ForwardIt
, class Size
, class T
>
989 ForwardIt
search_n (ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
990 Size count
, const T
& value
);
992 template <class ForwardIt
, class Size
, class T
, class BinaryPredicate
>
993 ForwardIt
search_n (ForwardIt first
, ForwardIt last
, Size count
,
994 const T
& value
, BinaryPredicate p
);
996 template <class ExecutionPolicy
, class ForwardIt
, class Size
, class T
,
997 class BinaryPredicate
>
998 ForwardIt
search_n (ExecutionPolicy
&& policy
, ForwardIt first
, ForwardIt last
,
999 Size count
, const T
& value
, BinaryPredicate p
);
1001 template <class InputIterator
, class OutputIterator
>
1002 OutputIterator
copy(InputIterator first
, InputIterator last
,
1003 OutputIterator result
);
1007 #if __cplusplus >= 201103L
1009 template <typename T
> // TODO: Implement the stub for deleter.
1012 unique_ptr() noexcept
{}
1013 unique_ptr(T
*) noexcept
{}
1014 unique_ptr(const unique_ptr
&) noexcept
= delete;
1015 unique_ptr(unique_ptr
&&) noexcept
;
1017 T
*get() const noexcept
;
1018 T
*release() noexcept
;
1019 void reset(T
*p
= nullptr) noexcept
;
1020 void swap(unique_ptr
<T
> &p
) noexcept
;
1022 typename
std::add_lvalue_reference
<T
>::type
operator*() const;
1023 T
*operator->() const noexcept
;
1024 operator bool() const noexcept
;
1025 unique_ptr
<T
> &operator=(unique_ptr
<T
> &&p
) noexcept
;
1026 unique_ptr
<T
> &operator=(nullptr_t
) noexcept
;
1029 // TODO :: Once the deleter parameter is added update with additional template parameter.
1030 template <typename T
>
1031 void swap(unique_ptr
<T
> &x
, unique_ptr
<T
> &y
) noexcept
{
1035 template <typename T1
, typename T2
>
1036 bool operator==(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1038 template <typename T1
, typename T2
>
1039 bool operator!=(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1041 template <typename T1
, typename T2
>
1042 bool operator<(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1044 template <typename T1
, typename T2
>
1045 bool operator>(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1047 template <typename T1
, typename T2
>
1048 bool operator<=(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1050 template <typename T1
, typename T2
>
1051 bool operator>=(const unique_ptr
<T1
> &x
, const unique_ptr
<T2
> &y
);
1053 template <typename T
>
1054 bool operator==(const unique_ptr
<T
> &x
, nullptr_t y
);
1056 template <typename T
>
1057 bool operator!=(const unique_ptr
<T
> &x
, nullptr_t y
);
1059 template <typename T
>
1060 bool operator<(const unique_ptr
<T
> &x
, nullptr_t y
);
1062 template <typename T
>
1063 bool operator>(const unique_ptr
<T
> &x
, nullptr_t y
);
1065 template <typename T
>
1066 bool operator<=(const unique_ptr
<T
> &x
, nullptr_t y
);
1068 template <typename T
>
1069 bool operator>=(const unique_ptr
<T
> &x
, nullptr_t y
);
1071 template <typename T
>
1072 bool operator==(nullptr_t x
, const unique_ptr
<T
> &y
);
1074 template <typename T
>
1075 bool operator!=(nullptr_t x
, const unique_ptr
<T
> &y
);
1077 template <typename T
>
1078 bool operator>(nullptr_t x
, const unique_ptr
<T
> &y
);
1080 template <typename T
>
1081 bool operator<(nullptr_t x
, const unique_ptr
<T
> &y
);
1083 template <typename T
>
1084 bool operator>=(nullptr_t x
, const unique_ptr
<T
> &y
);
1086 template <typename T
>
1087 bool operator<=(nullptr_t x
, const unique_ptr
<T
> &y
);
1089 template <class T
, class... Args
>
1090 unique_ptr
<T
> make_unique(Args
&&...args
);
1092 #if __cplusplus >= 202002L
1095 unique_ptr
<T
> make_unique_for_overwrite();
1103 template <class CharT
>
1104 class basic_ostream
;
1106 using ostream
= basic_ostream
<char>;
1108 extern std::ostream cout
;
1110 ostream
&operator<<(ostream
&, const string
&);
1112 #if __cplusplus >= 202002L
1114 ostream
&operator<<(ostream
&, const std::unique_ptr
<T
> &);
1117 template <class CharT
>
1118 class basic_istream
;
1120 using istream
= basic_istream
<char>;
1122 extern std::istream cin
;
1124 istream
&getline(istream
&, string
&, char);
1125 istream
&getline(istream
&, string
&);
1129 void *malloc(size_t);
1133 #ifdef TEST_INLINABLE_ALLOCATORS
1134 void* operator new(std::size_t size
, const std::nothrow_t
&) throw() { return std::malloc(size
); }
1135 void* operator new[](std::size_t size
, const std::nothrow_t
&) throw() { return std::malloc(size
); }
1136 void operator delete(void* ptr
, const std::nothrow_t
&) throw() { std::free(ptr
); }
1137 void operator delete[](void* ptr
, const std::nothrow_t
&) throw() { std::free(ptr
); }
1139 // C++20 standard draft 17.6.1, from "Header <new> synopsis", but with throw()
1140 // instead of noexcept:
1142 void *operator new(std::size_t size
);
1143 void *operator new(std::size_t size
, std::align_val_t alignment
);
1144 void *operator new(std::size_t size
, const std::nothrow_t
&) throw();
1145 void *operator new(std::size_t size
, std::align_val_t alignment
,
1146 const std::nothrow_t
&) throw();
1147 void operator delete(void *ptr
) throw();
1148 void operator delete(void *ptr
, std::size_t size
) throw();
1149 void operator delete(void *ptr
, std::align_val_t alignment
) throw();
1150 void operator delete(void *ptr
, std::size_t size
, std::align_val_t alignment
) throw();
1151 void operator delete(void *ptr
, const std::nothrow_t
&)throw();
1152 void operator delete(void *ptr
, std::align_val_t alignment
,
1153 const std::nothrow_t
&)throw();
1154 void *operator new[](std::size_t size
);
1155 void *operator new[](std::size_t size
, std::align_val_t alignment
);
1156 void *operator new[](std::size_t size
, const std::nothrow_t
&) throw();
1157 void *operator new[](std::size_t size
, std::align_val_t alignment
,
1158 const std::nothrow_t
&) throw();
1159 void operator delete[](void *ptr
) throw();
1160 void operator delete[](void *ptr
, std::size_t size
) throw();
1161 void operator delete[](void *ptr
, std::align_val_t alignment
) throw();
1162 void operator delete[](void *ptr
, std::size_t size
, std::align_val_t alignment
) throw();
1163 void operator delete[](void *ptr
, const std::nothrow_t
&) throw();
1164 void operator delete[](void *ptr
, std::align_val_t alignment
,
1165 const std::nothrow_t
&) throw();
1168 void* operator new (std::size_t size
, void* ptr
) throw() { return ptr
; };
1169 void* operator new[] (std::size_t size
, void* ptr
) throw() { return ptr
; };
1170 void operator delete (void* ptr
, void*) throw() {};
1171 void operator delete[] (void* ptr
, void*) throw() {};
1173 namespace __cxxabiv1
{
1175 extern char *__cxa_demangle(const char *mangled_name
,
1176 char *output_buffer
,
1180 namespace abi
= __cxxabiv1
;
1183 template<class ForwardIt
>
1184 bool is_sorted(ForwardIt first
, ForwardIt last
);
1186 template <class RandomIt
>
1187 void nth_element(RandomIt first
, RandomIt nth
, RandomIt last
);
1189 template<class RandomIt
>
1190 void partial_sort(RandomIt first
, RandomIt middle
, RandomIt last
);
1192 template<class RandomIt
>
1193 void sort (RandomIt first
, RandomIt last
);
1195 template<class RandomIt
>
1196 void stable_sort(RandomIt first
, RandomIt last
);
1198 template<class BidirIt
, class UnaryPredicate
>
1199 BidirIt
partition(BidirIt first
, BidirIt last
, UnaryPredicate p
);
1201 template<class BidirIt
, class UnaryPredicate
>
1202 BidirIt
stable_partition(BidirIt first
, BidirIt last
, UnaryPredicate p
);
1207 template< class T
= void >
1213 template< class Key
>
1218 class Compare
= std::less
<Key
>,
1219 class Alloc
= std::allocator
<Key
>
1222 set(initializer_list
<Key
> __list
) {}
1226 iterator(Key
*key
): ptr(key
) {}
1227 iterator
& operator++() { ++ptr
; return *this; }
1228 bool operator!=(const iterator
&other
) const { return ptr
!= other
.ptr
; }
1229 const Key
&operator*() const { return *ptr
; }
1236 iterator
begin() const { return iterator(val
); }
1237 iterator
end() const { return iterator(val
+ 1); }
1242 class Hash
= std::hash
<Key
>,
1243 class Compare
= std::less
<Key
>,
1244 class Alloc
= std::allocator
<Key
>
1245 > class unordered_set
{
1247 unordered_set(initializer_list
<Key
> __list
) {}
1251 iterator(Key
*key
): ptr(key
) {}
1252 iterator
& operator++() { ++ptr
; return *this; }
1253 bool operator!=(const iterator
&other
) const { return ptr
!= other
.ptr
; }
1254 const Key
&operator*() const { return *ptr
; }
1261 iterator
begin() const { return iterator(val
); }
1262 iterator
end() const { return iterator(val
+ 1); }
1265 template <typename T
>
1272 namespace execution
{
1273 class sequenced_policy
{};
1276 template <class T
= void> struct equal_to
{};
1278 template <class ForwardIt
, class BinaryPredicate
= std::equal_to
<> >
1279 class default_searcher
{
1281 default_searcher (ForwardIt pat_first
,
1283 BinaryPredicate pred
= BinaryPredicate());
1284 template <class ForwardIt2
>
1285 std::pair
<ForwardIt2
, ForwardIt2
>
1286 operator()( ForwardIt2 first
, ForwardIt2 last
) const;
1289 template <typename
> class packaged_task
;
1290 template <typename Ret
, typename
... Args
> class packaged_task
<Ret(Args
...)> {
1291 // TODO: Add some actual implementation.
1294 #if __cplusplus >= 201703L
1299 struct type_identity
{ using type
= T
; }; // or use std::type_identity (since C++20)
1302 auto try_add_pointer(int) -> type_identity
<typename
std::remove_reference
<T
>::type
*>;
1304 auto try_add_pointer(...) -> type_identity
<T
>;
1305 } // namespace detail
1308 struct add_pointer
: decltype(detail::try_add_pointer
<T
>(0)) {};
1311 using add_pointer_t
= typename add_pointer
<T
>::type
;
1313 template<class T
> struct remove_cv
{ typedef T type
; };
1314 template<class T
> struct remove_cv
<const T
> { typedef T type
; };
1315 template<class T
> struct remove_cv
<volatile T
> { typedef T type
; };
1316 template<class T
> struct remove_cv
<const volatile T
> { typedef T type
; };
1319 using remove_cv_t
= typename remove_cv
<T
>::type
;
1321 // This decay does not behave exactly like std::decay, but this is enough
1322 // for testing the std::variant checker
1324 struct decay
{typedef remove_cv_t
<remove_reference_t
<T
>> type
;};
1326 using decay_t
= typename decay
<T
>::type
;
1329 template <class... Types
> class variant
;
1330 // variant helper classes
1331 template <class T
> struct variant_size
;
1332 template <class T
> struct variant_size
<const T
>;
1333 template <class T
> struct variant_size
<volatile T
>;
1334 template <class T
> struct variant_size
<const volatile T
>;
1335 template <class T
> inline constexpr size_t variant_size_v
= variant_size
<T
>::value
;
1336 template <class... Types
>
1337 struct variant_size
<variant
<Types
...>>;
1338 template <size_t I
, class T
> struct variant_alternative
;
1339 template <size_t I
, class T
> struct variant_alternative
<I
, const T
>;
1340 template <size_t I
, class T
> struct variant_alternative
<I
, volatile T
>;
1341 template <size_t I
, class T
> struct variant_alternative
<I
, const volatile T
>;
1342 template <size_t I
, class T
>
1343 using variant_alternative_t
= typename variant_alternative
<I
, T
>::type
;
1344 template <size_t I
, class... Types
>
1345 struct variant_alternative
<I
, variant
<Types
...>>;
1346 inline constexpr size_t variant_npos
= -1;
1347 template <size_t I
, class... Types
>
1348 constexpr variant_alternative_t
<I
, variant
<Types
...>>&
1349 get(variant
<Types
...>&);
1350 template <size_t I
, class... Types
>
1351 constexpr variant_alternative_t
<I
, variant
<Types
...>>&&
1352 get(variant
<Types
...>&&);
1353 template <size_t I
, class... Types
>
1354 constexpr const variant_alternative_t
<I
, variant
<Types
...>>&
1355 get(const variant
<Types
...>&);
1356 template <size_t I
, class... Types
>
1357 constexpr const variant_alternative_t
<I
, variant
<Types
...>>&&
1358 get(const variant
<Types
...>&&);
1359 template <class T
, class... Types
>
1360 constexpr T
& get(variant
<Types
...>&);
1361 template <class T
, class... Types
>
1362 constexpr T
&& get(variant
<Types
...>&&);
1363 template <class T
, class... Types
>
1364 constexpr const T
& get(const variant
<Types
...>&);
1365 template <class T
, class... Types
>
1366 constexpr const T
&& get(const variant
<Types
...>&&);
1367 template <size_t I
, class... Types
>
1368 constexpr add_pointer_t
<variant_alternative_t
<I
, variant
<Types
...>>>
1369 get_if(variant
<Types
...>*) noexcept
;
1370 template <size_t I
, class... Types
>
1371 constexpr add_pointer_t
<const variant_alternative_t
<I
, variant
<Types
...>>>
1372 get_if(const variant
<Types
...>*) noexcept
;
1373 template <class T
, class... Types
>
1374 constexpr add_pointer_t
<T
> get_if(variant
<Types
...>*) noexcept
;
1375 template <class T
, class... Types
>
1376 constexpr add_pointer_t
<const T
> get_if(const variant
<Types
...>*) noexcept
;
1378 template <class... Types
>
1382 constexpr variant()= default ;
1383 constexpr variant(const variant
&);
1384 constexpr variant(variant
&&);
1385 template<typename T
,
1386 typename
= std::enable_if_t
<!is_same_v
<std::variant
<Types
...>, decay_t
<T
>>>>
1387 constexpr variant(T
&&);
1389 variant
& operator=(const variant
&);
1390 variant
& operator=(variant
&&) ;
1391 template<typename T
,
1392 typename
= std::enable_if_t
<!is_same_v
<std::variant
<Types
...>, decay_t
<T
>>>>
1393 variant
& operator=(T
&&);