1// { dg-do compile } 2// { dg-options "-fgnu-tm" } 3 4typedef long int ptrdiff_t; 5typedef long unsigned int size_t; 6namespace std __attribute__ ((__visibility__ ("default"))) 7{ 8 using::ptrdiff_t; 9 using::size_t; 10} 11 12namespace std __attribute__ ((__visibility__ ("default"))) 13{ 14 struct input_iterator_tag 15 { 16 }; 17 struct output_iterator_tag 18 { 19 }; 20 struct forward_iterator_tag:public input_iterator_tag 21 { 22 }; 23 struct bidirectional_iterator_tag:public forward_iterator_tag 24 { 25 }; 26 struct random_access_iterator_tag:public bidirectional_iterator_tag 27 { 28 }; 29 template < typename _Category, typename _Tp, typename _Distance = 30 ptrdiff_t, typename _Pointer = _Tp *, typename _Reference = 31 _Tp & >struct iterator 32 { 33 typedef _Category iterator_category; 34 typedef _Tp value_type; 35 typedef _Distance difference_type; 36 typedef _Pointer pointer; 37 typedef _Reference reference; 38 }; 39 template < typename _Iterator > struct iterator_traits 40 { 41 typedef typename _Iterator::iterator_category iterator_category; 42 typedef typename _Iterator::value_type value_type; 43 typedef typename _Iterator::difference_type difference_type; 44 typedef typename _Iterator::pointer pointer; 45 typedef typename _Iterator::reference reference; 46 }; 47 template < typename _Tp > struct iterator_traits <_Tp * > 48 { 49 typedef random_access_iterator_tag iterator_category; 50 typedef _Tp value_type; 51 typedef ptrdiff_t difference_type; 52 typedef _Tp *pointer; 53 typedef _Tp & reference; 54 }; 55 template < typename _Tp > struct iterator_traits <const _Tp *> 56 { 57 typedef random_access_iterator_tag iterator_category; 58 typedef _Tp value_type; 59 typedef ptrdiff_t difference_type; 60 typedef const _Tp *pointer; 61 typedef const _Tp & reference; 62 }; 63 template < typename _Iter > inline typename iterator_traits < 64 _Iter >::iterator_category __iterator_category (const _Iter &) 65 { 66 return typename iterator_traits < _Iter >::iterator_category (); 67 } 68} 69 70namespace std __attribute__ ((__visibility__ ("default"))) 71{ 72template < typename _Iterator > class reverse_iterator:public iterator < typename iterator_traits < _Iterator >::iterator_category, 73 typename iterator_traits < _Iterator >::value_type, 74 typename iterator_traits < _Iterator >::difference_type, 75 typename iterator_traits < _Iterator >::pointer, 76 typename iterator_traits < _Iterator >::reference > 77 { 78 protected:_Iterator current; 79 typedef iterator_traits < _Iterator > __traits_type; 80 public:typedef _Iterator iterator_type; 81 typedef typename __traits_type::difference_type difference_type; 82 typedef typename __traits_type::pointer pointer; 83 typedef typename __traits_type::reference reference; 84 reverse_iterator ():current () 85 { 86 } explicit reverse_iterator (iterator_type __x):current (__x) 87 { 88 } reverse_iterator (const reverse_iterator & __x):current (__x.current) 89 { 90 } template < typename _Iter > reverse_iterator (const reverse_iterator < 91 _Iter > 92 &__x):current (__x. 93 base ()) 94 { 95 } iterator_type base () const 96 { 97 return current; 98 } 99 reference operator* () const 100 { 101 _Iterator __tmp = current; 102 return *--__tmp; 103 } 104 pointer operator-> () const 105 { 106 return &(operator* ()); 107 } 108 reverse_iterator & operator++ () 109 { 110 --current; 111 return *this; 112 } 113 reverse_iterator operator++ (int) 114 { 115 reverse_iterator __tmp = *this; 116 --current; 117 return __tmp; 118 } 119 reverse_iterator & operator-- () 120 { 121 ++current; 122 return *this; 123 } 124 reverse_iterator operator-- (int) 125 { 126 reverse_iterator __tmp = *this; 127 ++current; 128 return __tmp; 129 } 130 reverse_iterator operator+ (difference_type __n) const 131 { 132 return reverse_iterator (current - __n); 133 } 134 reverse_iterator & operator+= (difference_type __n) 135 { 136 current -= __n; 137 return *this; 138 } 139 reverse_iterator operator- (difference_type __n) const 140 { 141 return reverse_iterator (current + __n); 142 } 143 reverse_iterator & operator-= (difference_type __n) 144 { 145 current += __n; 146 return *this; 147 } 148 reference operator[] (difference_type __n) const 149 { 150 return *(*this + __n); 151 } 152 }; 153 template < typename _Iterator > 154 inline bool operator== (const reverse_iterator < _Iterator > &__x, 155 const reverse_iterator < _Iterator > &__y) 156 { 157 return __x.base () == __y.base (); 158 } 159 template < typename _Iterator > 160 inline bool operator< (const reverse_iterator < _Iterator > &__x, 161 const reverse_iterator < _Iterator > &__y) 162 { 163 return __y.base () < __x.base (); 164 } 165 template < typename _Iterator > 166 inline bool operator!= (const reverse_iterator < _Iterator > &__x, 167 const reverse_iterator < _Iterator > &__y) 168 { 169 return !(__x == __y); 170 } 171 template < typename _Iterator > 172 inline bool operator> (const reverse_iterator < _Iterator > &__x, 173 const reverse_iterator < _Iterator > &__y) 174 { 175 return __y < __x; 176 } 177 template < typename _Iterator > 178 inline bool operator<= (const reverse_iterator < _Iterator > &__x, 179 const reverse_iterator < _Iterator > &__y) 180 { 181 return !(__y < __x); 182 } 183 template < typename _Iterator > 184 inline bool operator>= (const reverse_iterator < _Iterator > &__x, 185 const reverse_iterator < _Iterator > &__y) 186 { 187 return !(__x < __y); 188 } 189 template < typename _Iterator > inline typename reverse_iterator < 190 _Iterator >::difference_type operator- (const reverse_iterator < 191 _Iterator > &__x, 192 const reverse_iterator < 193 _Iterator > &__y) 194 { 195 return __y.base () - __x.base (); 196 } 197 template < typename _Iterator > inline reverse_iterator < _Iterator > 198 operator+ (typename reverse_iterator < _Iterator >::difference_type __n, 199 const reverse_iterator < _Iterator > &__x) 200 { 201 return reverse_iterator < _Iterator > (__x.base () - __n); 202 } 203 template < typename _IteratorL, 204 typename _IteratorR > inline bool operator== (const reverse_iterator < 205 _IteratorL > &__x, 206 const reverse_iterator < 207 _IteratorR > &__y) 208 { 209 return __x.base () == __y.base (); 210 } 211 template < typename _IteratorL, 212 typename _IteratorR > inline bool operator< (const reverse_iterator < 213 _IteratorL > &__x, 214 const reverse_iterator < 215 _IteratorR > &__y) 216 { 217 return __y.base () < __x.base (); 218 } 219 template < typename _IteratorL, 220 typename _IteratorR > inline bool operator!= (const reverse_iterator < 221 _IteratorL > &__x, 222 const reverse_iterator < 223 _IteratorR > &__y) 224 { 225 return !(__x == __y); 226 } 227 template < typename _IteratorL, 228 typename _IteratorR > inline bool operator> (const reverse_iterator < 229 _IteratorL > &__x, 230 const reverse_iterator < 231 _IteratorR > &__y) 232 { 233 return __y < __x; 234 } 235 template < typename _IteratorL, 236 typename _IteratorR > inline bool operator<= (const reverse_iterator < 237 _IteratorL > &__x, 238 const reverse_iterator < 239 _IteratorR > &__y) 240 { 241 return !(__y < __x); 242 } 243 template < typename _IteratorL, 244 typename _IteratorR > inline bool operator>= (const reverse_iterator < 245 _IteratorL > &__x, 246 const reverse_iterator < 247 _IteratorR > &__y) 248 { 249 return !(__x < __y); 250 } 251 template < typename _IteratorL, 252 typename _IteratorR > inline typename reverse_iterator < 253 _IteratorL >::difference_type operator- (const reverse_iterator < 254 _IteratorL > &__x, 255 const reverse_iterator < 256 _IteratorR > &__y) 257 { 258 return __y.base () - __x.base (); 259 } 260template < typename _Container > class back_insert_iterator:public iterator < output_iterator_tag, void, void, void, 261 void > 262 { 263 protected:_Container * container; 264 public:typedef _Container container_type; 265 explicit back_insert_iterator (_Container & __x):container (&__x) 266 { 267 } back_insert_iterator & operator= (typename _Container:: 268 const_reference __value) 269 { 270 container->push_back (__value); 271 return *this; 272 } 273 back_insert_iterator & operator* () 274 { 275 return *this; 276 } 277 back_insert_iterator & operator++ () 278 { 279 return *this; 280 } 281 back_insert_iterator operator++ (int) 282 { 283 return *this; 284 } 285 }; 286 template < typename _Container > inline back_insert_iterator < _Container > 287 back_inserter (_Container & __x) 288 { 289 return back_insert_iterator < _Container > (__x); 290 } 291template < typename _Container > class front_insert_iterator:public iterator < output_iterator_tag, void, void, void, 292 void > 293 { 294 protected:_Container * container; 295 public:typedef _Container container_type; 296 explicit front_insert_iterator (_Container & __x):container (&__x) 297 { 298 } front_insert_iterator & operator= (typename _Container:: 299 const_reference __value) 300 { 301 container->push_front (__value); 302 return *this; 303 } 304 front_insert_iterator & operator* () 305 { 306 return *this; 307 } 308 front_insert_iterator & operator++ () 309 { 310 return *this; 311 } 312 front_insert_iterator operator++ (int) 313 { 314 return *this; 315 } 316 }; 317 template < typename _Container > inline front_insert_iterator < _Container > 318 front_inserter (_Container & __x) 319 { 320 return front_insert_iterator < _Container > (__x); 321 } 322template < typename _Container > class insert_iterator:public iterator < output_iterator_tag, void, void, void, 323 void > 324 { 325 protected:_Container * container; 326 typename _Container::iterator iter; 327 public:typedef _Container container_type; 328 insert_iterator (_Container & __x, 329 typename _Container::iterator __i):container (&__x), 330 iter (__i) 331 { 332 } insert_iterator & operator= (typename _Container:: 333 const_reference __value) 334 { 335 iter = container->insert (iter, __value); 336 ++iter; 337 return *this; 338 } 339 insert_iterator & operator* () 340 { 341 return *this; 342 } 343 insert_iterator & operator++ () 344 { 345 return *this; 346 } 347 insert_iterator & operator++ (int) 348 { 349 return *this; 350 } 351 }; 352 template < typename _Container, 353 typename _Iterator > inline insert_iterator < _Container > 354 inserter (_Container & __x, _Iterator __i) 355 { 356 return insert_iterator < _Container > (__x, 357 typename _Container:: 358 iterator (__i)); 359 } 360} 361 362namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) 363{ 364 using std::size_t; 365 using std::ptrdiff_t; 366 template < typename _Tp > class new_allocator 367 { 368 public:typedef size_t size_type; 369 typedef ptrdiff_t difference_type; 370 typedef _Tp *pointer; 371 typedef const _Tp *const_pointer; 372 typedef _Tp & reference; 373 typedef const _Tp & const_reference; 374 typedef _Tp value_type; 375 template < typename _Tp1 > struct rebind 376 { 377 typedef new_allocator < _Tp1 > other; 378 }; 379 new_allocator ()throw () 380 { 381 } new_allocator (const new_allocator &) throw () 382 { 383 } template < typename _Tp1 > new_allocator (const new_allocator < _Tp1 > 384 &) throw () 385 { 386 } ~new_allocator ()throw () 387 { 388 } pointer address (reference __x) const 389 { 390 return &__x; 391 } 392 const_pointer address (const_reference __x) const 393 { 394 return &__x; 395 } 396 pointer allocate (size_type __n, const void * = 0) 397 { 398 return static_cast < _Tp * >(::operator new (__n * sizeof (_Tp))); 399 } 400 void deallocate (pointer __p, size_type) 401 { 402 ::operator delete (__p); 403 } size_type max_size () const throw () 404 { 405 return size_t (-1) / sizeof (_Tp); 406 } 407 void construct (pointer __p, const _Tp & __val) 408 { 409 ::new ((void *) __p) _Tp (__val); 410 } void destroy (pointer __p) 411 { 412 __p->~_Tp (); 413 }}; 414 template < typename _Tp > inline bool operator== (const new_allocator < 415 _Tp > &, 416 const new_allocator < 417 _Tp > &) 418 { 419 return true; 420 } 421 template < typename _Tp > inline bool operator!= (const new_allocator < 422 _Tp > &, 423 const new_allocator < 424 _Tp > &) 425 { 426 return false; 427 } 428} 429 430namespace std __attribute__ ((__visibility__ ("default"))) 431{ 432 template < typename _Tp > class allocator; 433 template <> class allocator < void > 434 { 435 public:typedef size_t size_type; 436 typedef ptrdiff_t difference_type; 437 typedef void *pointer; 438 typedef const void *const_pointer; 439 typedef void value_type; 440 template < typename _Tp1 > struct rebind 441 { 442 typedef allocator < _Tp1 > other; 443 }; 444 }; 445template < typename _Tp > class allocator:public __gnu_cxx::new_allocator < 446 _Tp > 447 { 448 public:typedef size_t size_type; 449 typedef ptrdiff_t difference_type; 450 typedef _Tp *pointer; 451 typedef const _Tp *const_pointer; 452 typedef _Tp & reference; 453 typedef const _Tp & const_reference; 454 typedef _Tp value_type; 455 template < typename _Tp1 > struct rebind 456 { 457 typedef allocator < _Tp1 > other; 458 }; 459 allocator ()throw () 460 { 461 } allocator (const allocator & __a) throw ():__gnu_cxx::new_allocator < 462 _Tp > (__a) 463 { 464 } template < typename _Tp1 > allocator (const allocator < _Tp1 > 465 &) throw () 466 { 467 } ~allocator ()throw () 468 { 469 }}; 470 template < typename _T1, 471 typename _T2 > inline bool operator== (const allocator < _T1 > &, 472 const allocator < _T2 > &) 473 { 474 return true; 475 } 476 template < typename _Tp > inline bool operator== (const allocator < _Tp > &, 477 const allocator < _Tp > &) 478 { 479 return true; 480 } 481 template < typename _T1, 482 typename _T2 > inline bool operator!= (const allocator < _T1 > &, 483 const allocator < _T2 > &) 484 { 485 return false; 486 } 487 template < typename _Tp > inline bool operator!= (const allocator < _Tp > &, 488 const allocator < _Tp > &) 489 { 490 return false; 491 } 492 template < typename _Alloc, bool = __is_empty (_Alloc) > struct __alloc_swap 493 { 494 static void _S_do_it (_Alloc &, _Alloc &) 495 { 496 }}; 497 template < typename _Alloc > struct __alloc_swap <_Alloc, false > 498 { 499 static void _S_do_it (_Alloc & __one, _Alloc & __two) 500 { 501 if (__one != __two) 502 swap (__one, __two); 503 } 504 }; 505 template < typename _Alloc, bool = __is_empty (_Alloc) > struct __alloc_neq 506 { 507 static bool _S_do_it (const _Alloc &, const _Alloc &) 508 { 509 return false; 510 } 511 }; 512 template < typename _Alloc > struct __alloc_neq <_Alloc, false > 513 { 514 static bool _S_do_it (const _Alloc & __one, const _Alloc & __two) 515 { 516 return __one != __two; 517 } 518 }; 519} 520 521namespace std __attribute__ ((__visibility__ ("default"))) 522{ 523 struct _List_node_base 524 { 525 _List_node_base *_M_next; 526 _List_node_base *_M_prev; 527 static void swap (_List_node_base & __x, _List_node_base & __y) throw (); 528 void _M_transfer (_List_node_base * const __first, 529 _List_node_base * const __last) throw (); 530 void _M_reverse () throw (); 531 void _M_hook (_List_node_base * const __position) throw (); 532 void _M_unhook () throw (); 533 }; 534 template < typename _Tp > struct _List_node:public _List_node_base 535 { 536 _Tp _M_data; 537 }; 538 template < typename _Tp > struct _List_iterator 539 { 540 typedef _List_iterator < _Tp > _Self; 541 typedef _List_node < _Tp > _Node; 542 typedef ptrdiff_t difference_type; 543 typedef std::bidirectional_iterator_tag iterator_category; 544 typedef _Tp value_type; 545 typedef _Tp *pointer; 546 typedef _Tp & reference; 547 _List_iterator ():_M_node () 548 { 549 } explicit _List_iterator (_List_node_base * __x):_M_node (__x) 550 { 551 } reference operator* () const 552 { 553 return static_cast < _Node * >(_M_node)->_M_data; 554 } 555 pointer operator-> () const 556 { 557 return &static_cast < _Node * >(_M_node)->_M_data; 558 } 559 _Self & operator++ () 560 { 561 _M_node = _M_node->_M_next; 562 return *this; 563 } 564 _Self operator++ (int) 565 { 566 _Self __tmp = *this; 567 _M_node = _M_node->_M_next; 568 return __tmp; 569 } 570 _Self & operator-- () 571 { 572 _M_node = _M_node->_M_prev; 573 return *this; 574 } 575 _Self operator-- (int) 576 { 577 _Self __tmp = *this; 578 _M_node = _M_node->_M_prev; 579 return __tmp; 580 } 581 bool operator== (const _Self & __x) const 582 { 583 return _M_node == __x._M_node; 584 } 585 bool operator!= (const _Self & __x) const 586 { 587 return _M_node != __x._M_node; 588 } 589 _List_node_base *_M_node; 590 }; 591 template < typename _Tp > struct _List_const_iterator 592 { 593 typedef _List_const_iterator < _Tp > _Self; 594 typedef const _List_node < _Tp > _Node; 595 typedef _List_iterator < _Tp > iterator; 596 typedef ptrdiff_t difference_type; 597 typedef std::bidirectional_iterator_tag iterator_category; 598 typedef _Tp value_type; 599 typedef const _Tp *pointer; 600 typedef const _Tp & reference; 601 _List_const_iterator ():_M_node () 602 { 603 } explicit _List_const_iterator (const _List_node_base * 604 __x):_M_node (__x) 605 { 606 } _List_const_iterator (const iterator & __x):_M_node (__x._M_node) 607 { 608 } reference operator* () const 609 { 610 return static_cast < _Node * >(_M_node)->_M_data; 611 } 612 pointer operator-> () const 613 { 614 return &static_cast < _Node * >(_M_node)->_M_data; 615 } 616 _Self & operator++ () 617 { 618 _M_node = _M_node->_M_next; 619 return *this; 620 } 621 _Self operator++ (int) 622 { 623 _Self __tmp = *this; 624 _M_node = _M_node->_M_next; 625 return __tmp; 626 } 627 _Self & operator-- () 628 { 629 _M_node = _M_node->_M_prev; 630 return *this; 631 } 632 _Self operator-- (int) 633 { 634 _Self __tmp = *this; 635 _M_node = _M_node->_M_prev; 636 return __tmp; 637 } 638 bool operator== (const _Self & __x) const 639 { 640 return _M_node == __x._M_node; 641 } 642 bool operator!= (const _Self & __x) const 643 { 644 return _M_node != __x._M_node; 645 } 646 const _List_node_base *_M_node; 647 }; 648 template < typename _Tp, typename _Alloc > class _List_base 649 { 650 protected:typedef typename _Alloc::template rebind < _List_node < _Tp > 651 >::other _Node_alloc_type; 652 typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type; 653 struct _List_impl:public _Node_alloc_type 654 { 655 _List_node_base _M_node; 656 _List_impl ():_Node_alloc_type (), _M_node () 657 { 658 } _List_impl (const _Node_alloc_type & __a):_Node_alloc_type (__a), 659 _M_node () 660 { 661 }}; 662 _List_impl _M_impl; 663 _List_node < _Tp > *_M_get_node () 664 { 665 return _M_impl._Node_alloc_type::allocate (1); 666 } 667 void _M_put_node (_List_node < _Tp > *__p) 668 { 669 _M_impl._Node_alloc_type::deallocate (__p, 1); 670 } public:typedef _Alloc allocator_type; 671 _Node_alloc_type & _M_get_Node_allocator () 672 { 673 return *static_cast < _Node_alloc_type * >(&this->_M_impl); 674 } 675 const _Node_alloc_type & _M_get_Node_allocator () const 676 { 677 return *static_cast < const _Node_alloc_type *>(&this->_M_impl); 678 } _Tp_alloc_type _M_get_Tp_allocator () const 679 { 680 return _Tp_alloc_type (_M_get_Node_allocator ()); 681 } 682 allocator_type get_allocator () const 683 { 684 return allocator_type (_M_get_Node_allocator ()); 685 } 686 _List_base ():_M_impl () 687 { 688 _M_init (); 689 } 690 _List_base (const allocator_type & __a):_M_impl (__a) 691 { 692 _M_init (); 693 } ~_List_base () 694 { 695 _M_clear (); 696 } void _M_clear (); 697 void _M_init () 698 { 699 this->_M_impl._M_node._M_next = &this->_M_impl._M_node; 700 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node; 701 }}; 702template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class list:protected _List_base < _Tp, 703 _Alloc 704 > 705 { 706 typedef typename _Alloc::value_type _Alloc_value_type; 707 typedef _List_base < _Tp, _Alloc > _Base; 708 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; 709 public:typedef _Tp value_type; 710 typedef typename _Tp_alloc_type::pointer pointer; 711 typedef typename _Tp_alloc_type::const_pointer const_pointer; 712 typedef typename _Tp_alloc_type::reference reference; 713 typedef typename _Tp_alloc_type::const_reference const_reference; 714 typedef _List_iterator < _Tp > iterator; 715 typedef _List_const_iterator < _Tp > const_iterator; 716 typedef std::reverse_iterator < const_iterator > const_reverse_iterator; 717 typedef std::reverse_iterator < iterator > reverse_iterator; 718 typedef size_t size_type; 719 typedef ptrdiff_t difference_type; 720 typedef _Alloc allocator_type; 721 protected:typedef _List_node < _Tp > _Node; 722 using _Base::_M_impl; 723 using _Base::_M_put_node; 724 using _Base::_M_get_node; 725 using _Base::_M_get_Tp_allocator; 726 using _Base::_M_get_Node_allocator; 727 public:iterator begin () 728 { 729 return iterator (this->_M_impl._M_node._M_next); 730 } 731 const_iterator begin () const 732 { 733 return const_iterator (this->_M_impl._M_node._M_next); 734 } 735 iterator end () 736 { 737 return iterator (&this->_M_impl._M_node); 738 } 739 void remove (const _Tp & __value); 740 template < typename _Predicate > void remove_if (_Predicate); 741 void _M_erase (iterator __position) 742 { 743 __position._M_node->_M_unhook (); 744 _Node *__n = static_cast < _Node * >(__position._M_node); 745 _M_get_Tp_allocator ().destroy (&__n->_M_data); 746 _M_put_node (__n); 747 } void _M_check_equal_allocators (list & __x) 748 { 749 if (std::__alloc_neq < 750 typename _Base::_Node_alloc_type >:: 751 _S_do_it (_M_get_Node_allocator (), __x._M_get_Node_allocator ())); 752 } 753 }; 754} 755 756namespace std __attribute__ ((__visibility__ ("default"))) 757{ 758 template < typename _Tp, typename _Alloc > void list < _Tp, 759 _Alloc >::remove (const value_type & __value) 760 { 761 iterator __first = begin (); 762 iterator __last = end (); 763 iterator __extra = __last; 764 while (__first != __last) 765 { 766 iterator __next = __first; 767 ++__next; 768 if (*__first == __value) 769 { 770 if (&*__first != &__value) 771 _M_erase (__first); 772 else 773 __extra = __first; 774 } 775 __first = __next; 776 } 777 if (__extra != __last) 778 _M_erase (__extra); 779 } 780} 781 782class Unit 783{ 784public:int dummy; 785}; 786class Building 787{ 788public:__attribute__ ((transaction_callable)) void removeUnitFromInside (Unit * 789 unit); 790 std::list < Unit * >unitsInside; 791}; 792void 793Building::removeUnitFromInside (Unit * unit) 794{ 795 unitsInside.remove (unit); 796} 797