2 // { dg-options "-fgnu-tm -O0"}
3 // { dg-additional-options "-Wno-return-type" }
5 namespace std __attribute__ ((__visibility__ ("default"))) {
6 template<class _T1, class _T2>
9 typedef _T1 first_type;
10 typedef _T2 second_type;
14 : first(), second() { }
15 pair(const _T1& __a, const _T2& __b)
16 : first(__a), second(__b) { }
21 typedef long int ptrdiff_t;
22 typedef __SIZE_TYPE__ size_t;
23 namespace std __attribute__ ((__visibility__ ("default"))) {
27 namespace std __attribute__ ((__visibility__ ("default"))) {
28 struct input_iterator_tag { };
29 struct output_iterator_tag { };
30 struct forward_iterator_tag : public input_iterator_tag { };
31 struct bidirectional_iterator_tag : public forward_iterator_tag { };
32 struct random_access_iterator_tag : public bidirectional_iterator_tag { };
33 template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
34 typename _Pointer = _Tp*, typename _Reference = _Tp&>
37 typedef _Category iterator_category;
38 typedef _Tp value_type;
39 typedef _Distance difference_type;
40 typedef _Pointer pointer;
41 typedef _Reference reference;
43 template<typename _Iterator>
44 struct iterator_traits
46 typedef typename _Iterator::iterator_category iterator_category;
47 typedef typename _Iterator::value_type value_type;
48 typedef typename _Iterator::difference_type difference_type;
49 typedef typename _Iterator::pointer pointer;
50 typedef typename _Iterator::reference reference;
52 template<typename _Tp>
53 struct iterator_traits<_Tp*>
55 typedef random_access_iterator_tag iterator_category;
56 typedef _Tp value_type;
57 typedef ptrdiff_t difference_type;
59 typedef _Tp& reference;
61 template<typename _Tp>
62 struct iterator_traits<const _Tp*>
64 typedef random_access_iterator_tag iterator_category;
65 typedef _Tp value_type;
66 typedef ptrdiff_t difference_type;
67 typedef const _Tp* pointer;
68 typedef const _Tp& reference;
70 template<typename _Iter>
71 inline typename iterator_traits<_Iter>::iterator_category
72 __iterator_category(const _Iter&)
73 { return typename iterator_traits<_Iter>::iterator_category(); }
75 namespace std __attribute__ ((__visibility__ ("default"))) {
76 template<typename _Iterator>
77 class reverse_iterator
78 : public iterator<typename iterator_traits<_Iterator>::iterator_category,
79 typename iterator_traits<_Iterator>::value_type,
80 typename iterator_traits<_Iterator>::difference_type,
81 typename iterator_traits<_Iterator>::pointer,
82 typename iterator_traits<_Iterator>::reference>
86 typedef iterator_traits<_Iterator> __traits_type;
88 typedef _Iterator iterator_type;
89 typedef typename __traits_type::difference_type difference_type;
90 typedef typename __traits_type::pointer pointer;
91 typedef typename __traits_type::reference reference;
92 reverse_iterator() : current() { }
94 reverse_iterator(iterator_type __x) : current(__x) { }
95 reverse_iterator(const reverse_iterator& __x)
96 : current(__x.current) { }
97 template<typename _Iter>
98 reverse_iterator(const reverse_iterator<_Iter>& __x)
99 : current(__x.base()) { }
106 _Iterator __tmp = current;
111 { return &(operator*()); }
121 reverse_iterator __tmp = *this;
134 reverse_iterator __tmp = *this;
139 operator+(difference_type __n) const
140 { return reverse_iterator(current - __n); }
142 operator+=(difference_type __n)
148 operator-(difference_type __n) const
149 { return reverse_iterator(current + __n); }
151 operator-=(difference_type __n)
157 operator[](difference_type __n) const
158 { return *(*this + __n); }
170 exception() throw() { }
171 virtual ~exception() throw();
172 virtual const char* what() const throw();
174 class bad_exception : public exception
177 bad_exception() throw() { }
178 virtual ~bad_exception() throw();
179 virtual const char* what() const throw();
181 typedef void (*terminate_handler) ();
182 typedef void (*unexpected_handler) ();
183 terminate_handler set_terminate(terminate_handler) throw();
184 void terminate() throw() __attribute__ ((__noreturn__));
185 unexpected_handler set_unexpected(unexpected_handler) throw();
186 void unexpected() __attribute__ ((__noreturn__));
187 bool uncaught_exception() throw() __attribute__ ((__pure__));
189 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
190 void __verbose_terminate_handler();
196 class bad_alloc : public exception
199 bad_alloc() throw() { }
200 virtual ~bad_alloc() throw();
201 virtual const char* what() const throw();
203 struct nothrow_t { };
204 extern const nothrow_t nothrow;
205 typedef void (*new_handler)();
206 new_handler set_new_handler(new_handler) throw();
209 void* operator new(std::size_t, const std::nothrow_t&) throw();
210 void* operator new[](std::size_t, const std::nothrow_t&) throw();
211 void operator delete(void*, const std::nothrow_t&) throw();
212 void operator delete[](void*, const std::nothrow_t&) throw();
213 inline void* operator new(std::size_t, void* __p) throw() { return __p; }
214 inline void* operator new[](std::size_t, void* __p) throw() { return __p; }
215 inline void operator delete (void*, void*) throw() { }
216 inline void operator delete[](void*, void*) throw() { }
218 namespace std __attribute__ ((__visibility__ ("default"))) {
220 __throw_bad_exception(void) __attribute__((__noreturn__));
221 __attribute__((transaction_safe))
223 __throw_bad_alloc(void) __attribute__((__noreturn__));
225 __throw_bad_cast(void) __attribute__((__noreturn__));
227 __throw_bad_typeid(void) __attribute__((__noreturn__));
229 __throw_logic_error(const char*) __attribute__((__noreturn__));
231 __throw_domain_error(const char*) __attribute__((__noreturn__));
233 __throw_invalid_argument(const char*) __attribute__((__noreturn__));
235 __throw_length_error(const char*) __attribute__((__noreturn__));
237 __throw_out_of_range(const char*) __attribute__((__noreturn__));
239 __throw_runtime_error(const char*) __attribute__((__noreturn__));
241 __throw_range_error(const char*) __attribute__((__noreturn__));
243 __throw_overflow_error(const char*) __attribute__((__noreturn__));
245 __throw_underflow_error(const char*) __attribute__((__noreturn__));
247 __throw_ios_failure(const char*) __attribute__((__noreturn__));
249 __throw_system_error(int) __attribute__((__noreturn__));
251 __throw_future_error(int) __attribute__((__noreturn__));
253 __throw_bad_function_call() __attribute__((__noreturn__));
257 namespace std __attribute__ ((__visibility__ ("default"))) {
258 template<typename _Tp>
260 swap(_Tp& __a, _Tp& __b)
267 template<typename _Tp, size_t _Nm>
269 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
271 for (size_t __n = 0; __n < _Nm; ++__n)
272 swap(__a[__n], __b[__n]);
275 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
277 using std::ptrdiff_t;
278 template<typename _Tp>
282 typedef size_t size_type;
283 typedef ptrdiff_t difference_type;
284 typedef _Tp* pointer;
285 typedef const _Tp* const_pointer;
286 typedef _Tp& reference;
287 typedef const _Tp& const_reference;
288 typedef _Tp value_type;
289 template<typename _Tp1>
291 { typedef new_allocator<_Tp1> other; };
292 new_allocator() throw() { }
293 new_allocator(const new_allocator&) throw() { }
294 template<typename _Tp1>
295 new_allocator(const new_allocator<_Tp1>&) throw() { }
296 ~new_allocator() throw() { }
298 address(reference __x) const { return &__x; }
300 address(const_reference __x) const { return &__x; }
301 __attribute__((transaction_safe))
303 allocate(size_type __n, const void* = 0)
305 if (__n > this->max_size())
306 std::__throw_bad_alloc();
307 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
309 __attribute__((transaction_safe))
311 deallocate(pointer __p, size_type)
312 { ::operator delete(__p); }
314 max_size() const throw()
315 { return size_t(-1) / sizeof(_Tp); }
317 construct(pointer __p, const _Tp& __val)
318 { ::new((void *)__p) _Tp(__val); }
320 destroy(pointer __p) { __p->~_Tp(); }
322 template<typename _Tp>
324 operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
326 template<typename _Tp>
328 operator!=(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
331 namespace std __attribute__ ((__visibility__ ("default"))) {
332 template<typename _Tp>
335 class allocator<void>
338 typedef size_t size_type;
339 typedef ptrdiff_t difference_type;
340 typedef void* pointer;
341 typedef const void* const_pointer;
342 typedef void value_type;
343 template<typename _Tp1>
345 { typedef allocator<_Tp1> other; };
347 template<typename _Tp>
348 class allocator: public __gnu_cxx::new_allocator<_Tp>
351 typedef size_t size_type;
352 typedef ptrdiff_t difference_type;
353 typedef _Tp* pointer;
354 typedef const _Tp* const_pointer;
355 typedef _Tp& reference;
356 typedef const _Tp& const_reference;
357 typedef _Tp value_type;
358 template<typename _Tp1>
360 { typedef allocator<_Tp1> other; };
361 allocator() throw() { }
362 allocator(const allocator& __a) throw()
363 : __gnu_cxx::new_allocator<_Tp>(__a) { }
364 template<typename _Tp1>
365 allocator(const allocator<_Tp1>&) throw() { }
366 ~allocator() throw() { }
368 template<typename _T1, typename _T2>
370 operator==(const allocator<_T1>&, const allocator<_T2>&)
372 template<typename _Tp>
374 operator==(const allocator<_Tp>&, const allocator<_Tp>&)
376 template<typename _T1, typename _T2>
378 operator!=(const allocator<_T1>&, const allocator<_T2>&)
380 template<typename _Tp>
382 operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
384 //extern template class allocator<char>;
385 // extern template class allocator<wchar_t>;
386 template<typename _Alloc, bool = __is_empty(_Alloc)>
388 { static void _S_do_it(_Alloc&, _Alloc&) { } };
389 template<typename _Alloc>
390 struct __alloc_swap<_Alloc, false>
393 _S_do_it(_Alloc& __one, _Alloc& __two)
399 template<typename _Alloc, bool = __is_empty(_Alloc)>
403 _S_do_it(const _Alloc&, const _Alloc&)
406 template<typename _Alloc>
407 struct __alloc_neq<_Alloc, false>
410 _S_do_it(const _Alloc& __one, const _Alloc& __two)
411 { return __one != __two; }
414 namespace std __attribute__ ((__visibility__ ("default"))) {
415 template<typename _Arg, typename _Result>
416 struct unary_function
418 typedef _Arg argument_type;
419 typedef _Result result_type;
421 template<typename _Arg1, typename _Arg2, typename _Result>
422 struct binary_function
424 typedef _Arg1 first_argument_type;
425 typedef _Arg2 second_argument_type;
426 typedef _Result result_type;
428 template<typename _Tp>
429 struct equal_to : public binary_function<_Tp, _Tp, bool>
432 operator()(const _Tp& __x, const _Tp& __y) const
433 { return __x == __y; }
435 template<typename _Tp>
436 struct not_equal_to : public binary_function<_Tp, _Tp, bool>
439 operator()(const _Tp& __x, const _Tp& __y) const
440 { return __x != __y; }
442 template<typename _Tp>
443 struct greater : public binary_function<_Tp, _Tp, bool>
446 operator()(const _Tp& __x, const _Tp& __y) const
447 { return __x > __y; }
449 template<typename _Tp>
450 struct less : public binary_function<_Tp, _Tp, bool>
453 operator()(const _Tp& __x, const _Tp& __y) const
454 { return __x < __y; }
456 template<typename _Tp>
457 struct _Identity : public unary_function<_Tp,_Tp>
460 operator()(_Tp& __x) const
463 operator()(const _Tp& __x) const
467 namespace std __attribute__ ((__visibility__ ("default"))) {
468 enum _Rb_tree_color { _S_red = false, _S_black = true };
469 struct _Rb_tree_node_base
471 typedef _Rb_tree_node_base* _Base_ptr;
472 typedef const _Rb_tree_node_base* _Const_Base_ptr;
473 _Rb_tree_color _M_color;
478 _S_minimum(_Base_ptr __x)
480 while (__x->_M_left != 0) __x = __x->_M_left;
483 static _Const_Base_ptr
484 _S_minimum(_Const_Base_ptr __x)
486 while (__x->_M_left != 0) __x = __x->_M_left;
490 _S_maximum(_Base_ptr __x)
492 while (__x->_M_right != 0) __x = __x->_M_right;
495 static _Const_Base_ptr
496 _S_maximum(_Const_Base_ptr __x)
498 while (__x->_M_right != 0) __x = __x->_M_right;
502 template<typename _Val>
503 struct _Rb_tree_node : public _Rb_tree_node_base
505 typedef _Rb_tree_node<_Val>* _Link_type;
508 __attribute__ ((__pure__)) _Rb_tree_node_base*
509 _Rb_tree_increment(_Rb_tree_node_base* __x) throw ();
510 __attribute__ ((__pure__)) const _Rb_tree_node_base*
511 _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ();
512 __attribute__ ((__pure__)) _Rb_tree_node_base*
513 _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ();
514 __attribute__ ((__pure__)) const _Rb_tree_node_base*
515 _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ();
516 template<typename _Tp>
517 struct _Rb_tree_iterator
519 typedef _Tp value_type;
520 typedef _Tp& reference;
521 typedef _Tp* pointer;
522 typedef bidirectional_iterator_tag iterator_category;
523 typedef ptrdiff_t difference_type;
524 typedef _Rb_tree_iterator<_Tp> _Self;
525 typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
526 typedef _Rb_tree_node<_Tp>* _Link_type;
530 _Rb_tree_iterator(_Link_type __x)
534 { return static_cast<_Link_type>(_M_node)->_M_value_field; }
537 { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
541 _M_node = _Rb_tree_increment(_M_node);
548 _M_node = _Rb_tree_increment(_M_node);
554 _M_node = _Rb_tree_decrement(_M_node);
561 _M_node = _Rb_tree_decrement(_M_node);
565 operator==(const _Self& __x) const
566 { return _M_node == __x._M_node; }
568 operator!=(const _Self& __x) const
569 { return _M_node != __x._M_node; }
572 template<typename _Tp>
573 struct _Rb_tree_const_iterator
575 typedef _Tp value_type;
576 typedef const _Tp& reference;
577 typedef const _Tp* pointer;
578 typedef _Rb_tree_iterator<_Tp> iterator;
579 typedef bidirectional_iterator_tag iterator_category;
580 typedef ptrdiff_t difference_type;
581 typedef _Rb_tree_const_iterator<_Tp> _Self;
582 typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
583 typedef const _Rb_tree_node<_Tp>* _Link_type;
584 _Rb_tree_const_iterator()
587 _Rb_tree_const_iterator(_Link_type __x)
589 _Rb_tree_const_iterator(const iterator& __it)
590 : _M_node(__it._M_node) { }
593 { return static_cast<_Link_type>(_M_node)->_M_value_field; }
596 { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
600 _M_node = _Rb_tree_increment(_M_node);
607 _M_node = _Rb_tree_increment(_M_node);
613 _M_node = _Rb_tree_decrement(_M_node);
620 _M_node = _Rb_tree_decrement(_M_node);
624 operator==(const _Self& __x) const
625 { return _M_node == __x._M_node; }
627 operator!=(const _Self& __x) const
628 { return _M_node != __x._M_node; }
632 _Rb_tree_insert_and_rebalance(const bool __insert_left,
633 _Rb_tree_node_base* __x,
634 _Rb_tree_node_base* __p,
635 _Rb_tree_node_base& __header) throw ();
637 _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
638 _Rb_tree_node_base& __header) throw ();
639 template<typename _Key, typename _Val, typename _KeyOfValue,
640 typename _Compare, typename _Alloc = allocator<_Val> >
643 typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
646 typedef _Rb_tree_node_base* _Base_ptr;
647 typedef const _Rb_tree_node_base* _Const_Base_ptr;
649 typedef _Key key_type;
650 typedef _Val value_type;
651 typedef value_type* pointer;
652 typedef const value_type* const_pointer;
653 typedef value_type& reference;
654 typedef const value_type& const_reference;
655 typedef _Rb_tree_node<_Val>* _Link_type;
656 typedef const _Rb_tree_node<_Val>* _Const_Link_type;
657 typedef size_t size_type;
658 typedef ptrdiff_t difference_type;
659 typedef _Alloc allocator_type;
661 _M_get_Node_allocator()
662 { return *static_cast<_Node_allocator*>(&this->_M_impl); }
663 const _Node_allocator&
664 _M_get_Node_allocator() const
665 { return *static_cast<const _Node_allocator*>(&this->_M_impl); }
667 get_allocator() const
668 { return allocator_type(_M_get_Node_allocator()); }
672 { return _M_impl._Node_allocator::allocate(1); }
673 __attribute__((transaction_safe))
675 _M_put_node(_Link_type __p)
676 { _M_impl._Node_allocator::deallocate(__p, 1); }
677 __attribute__((transaction_safe))
679 _M_create_node(const value_type& __x)
681 _Link_type __tmp = _M_get_node();
683 { get_allocator().construct(&__tmp->_M_value_field, __x); }
692 _M_destroy_node(_Link_type __p)
694 get_allocator().destroy(&__p->_M_value_field);
698 template<typename _Key_compare,
699 bool _Is_pod_comparator = __is_pod(_Key_compare)>
700 struct _Rb_tree_impl : public _Node_allocator
702 _Key_compare _M_key_compare;
703 _Rb_tree_node_base _M_header;
704 size_type _M_node_count;
706 : _Node_allocator(), _M_key_compare(), _M_header(),
709 _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
710 : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
717 this->_M_header._M_color = _S_red;
718 this->_M_header._M_parent = 0;
719 this->_M_header._M_left = &this->_M_header;
720 this->_M_header._M_right = &this->_M_header;
723 _Rb_tree_impl<_Compare> _M_impl;
727 { return this->_M_impl._M_header._M_parent; }
730 { return this->_M_impl._M_header._M_parent; }
733 { return this->_M_impl._M_header._M_left; }
736 { return this->_M_impl._M_header._M_left; }
739 { return this->_M_impl._M_header._M_right; }
742 { return this->_M_impl._M_header._M_right; }
745 { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
749 return static_cast<_Const_Link_type>
750 (this->_M_impl._M_header._M_parent);
754 { return static_cast<_Link_type>(&this->_M_impl._M_header); }
757 { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
758 static const_reference
759 _S_value(_Const_Link_type __x)
760 { return __x->_M_value_field; }
762 _S_key(_Const_Link_type __x)
763 { return _KeyOfValue()(_S_value(__x)); }
765 _S_left(_Base_ptr __x)
766 { return static_cast<_Link_type>(__x->_M_left); }
767 static _Const_Link_type
768 _S_left(_Const_Base_ptr __x)
769 { return static_cast<_Const_Link_type>(__x->_M_left); }
771 _S_right(_Base_ptr __x)
772 { return static_cast<_Link_type>(__x->_M_right); }
773 static _Const_Link_type
774 _S_right(_Const_Base_ptr __x)
775 { return static_cast<_Const_Link_type>(__x->_M_right); }
776 static const_reference
777 _S_value(_Const_Base_ptr __x)
778 { return static_cast<_Const_Link_type>(__x)->_M_value_field; }
780 _S_key(_Const_Base_ptr __x)
781 { return _KeyOfValue()(_S_value(__x)); }
783 typedef _Rb_tree_iterator<value_type> iterator;
784 typedef _Rb_tree_const_iterator<value_type> const_iterator;
785 typedef std::reverse_iterator<iterator> reverse_iterator;
786 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
789 _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
790 const value_type& __v);
796 return iterator(static_cast<_Link_type>
797 (this->_M_impl._M_header._M_left));
802 return const_iterator(static_cast<_Const_Link_type>
803 (this->_M_impl._M_header._M_left));
807 { return iterator(static_cast<_Link_type>(&this->_M_impl._M_header)); }
811 return const_iterator(static_cast<_Const_Link_type>
812 (&this->_M_impl._M_header));
815 _M_insert_unique(const value_type& __x);
817 template<typename _Key, typename _Val, typename _KeyOfValue,
818 typename _Compare, typename _Alloc>
819 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
820 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
821 _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)
823 _Link_type __z = _M_create_node(__v);
824 return iterator(__z);
826 template<typename _Key, typename _Val, typename _KeyOfValue,
827 typename _Compare, typename _Alloc>
828 pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
829 _Compare, _Alloc>::iterator, bool>
830 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
831 _M_insert_unique(const _Val& __v)
833 _Link_type __x = _M_begin();
834 _Link_type __y = _M_end();
835 iterator __j = iterator(__y);
836 return pair<iterator, bool>(_M_insert_(__x, __y, __v), true);
839 namespace std __attribute__ ((__visibility__ ("default"))) {
840 template<typename _Key, typename _Compare = std::less<_Key>,
841 typename _Alloc = std::allocator<_Key> >
845 typedef _Key key_type;
846 typedef _Key value_type;
847 typedef _Compare key_compare;
848 typedef _Compare value_compare;
849 typedef _Alloc allocator_type;
851 typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
852 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
853 key_compare, _Key_alloc_type> _Rep_type;
856 typedef typename _Key_alloc_type::pointer pointer;
857 typedef typename _Key_alloc_type::const_pointer const_pointer;
858 typedef typename _Key_alloc_type::reference reference;
859 typedef typename _Key_alloc_type::const_reference const_reference;
860 typedef typename _Rep_type::const_iterator iterator;
861 typedef typename _Rep_type::const_iterator const_iterator;
862 typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
863 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
864 typedef typename _Rep_type::size_type size_type;
865 typedef typename _Rep_type::difference_type difference_type;
866 std::pair<iterator, bool>
867 insert(const value_type& __x)
869 _M_t._M_insert_unique(__x);
873 __attribute__((transaction_pure))
874 void* operator new(size_t);
875 __attribute__((transaction_pure))
876 void operator delete(void*);
884 std::set<Widget *> widgets;
886 void addWidget(Widget* widget);
888 void Screen::addWidget(Widget* widget)
890 widgets.insert(widget);