]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / regression / rand / priority_queue / container_rand_regression_test.tcc
1 // -*- C++ -*-
2
3 // Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the terms
8 // of the GNU General Public License as published by the Free Software
9 // Foundation; either version 3, or (at your option) any later
10 // version.
11
12 // This library is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License
18 // along with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21
22 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
23
24 // Permission to use, copy, modify, sell, and distribute this software
25 // is hereby granted without fee, provided that the above copyright
26 // notice appears in all copies, and that both that copyright notice
27 // and this permission notice appear in supporting documentation. None
28 // of the above authors, nor IBM Haifa Research Laboratories, make any
29 // representation about the suitability of this software for any
30 // purpose. It is provided "as is" without express or implied
31 // warranty.
32
33 /**
34 * @file container_rand_regression_test.tcc
35 * Contains a random regression test for a specific container type.
36 */
37
38 #ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
39 #define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
40
41 // Constructor, copy constructor, assignment and destructor.
42 PB_DS_CLASS_T_DEC
43 PB_DS_CLASS_C_DEC::
44 container_rand_regression_test(unsigned long seed, size_t n, size_t m,
45 double tp, double ip, double dp, double ep,
46 double cp, double mp, bool disp)
47 : m_seed(seed == 0 ? twister_rand_gen::get_time_determined_seed(): seed),
48 m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep), m_cp(cp),
49 m_mp(mp), m_disp(disp), m_p_c(0)
50 { }
51
52 PB_DS_CLASS_T_DEC
53 PB_DS_CLASS_C_DEC::
54 ~container_rand_regression_test()
55 { }
56
57 PB_DS_CLASS_T_DEC
58 bool
59 PB_DS_CLASS_C_DEC::
60 default_constructor()
61 {
62 PB_DS_TRACE("default_constructor");
63 bool done = true;
64 m_alloc.set_probability(m_tp);
65
66 try
67 {
68 m_p_c = new Cntnr;
69 }
70 catch(__gnu_cxx::forced_error&)
71 {
72 done = false;
73 }
74
75 if (m_p_c)
76 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
77
78 return done;
79 }
80
81 PB_DS_CLASS_T_DEC
82 void
83 PB_DS_CLASS_C_DEC::
84 swap()
85 {
86 PB_DS_TRACE("swap");
87 m_alloc.set_probability(0);
88 Cntnr* p_c = new Cntnr;
89 m_alloc.set_probability(1);
90 p_c->swap(*m_p_c);
91 std::swap(p_c, m_p_c);
92 delete p_c;
93 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
94 }
95
96 PB_DS_CLASS_T_DEC
97 bool
98 PB_DS_CLASS_C_DEC::
99 copy_constructor()
100 {
101 PB_DS_TRACE("copy_constructor");
102 bool done = true;
103 Cntnr* p_c = 0;
104 m_alloc.set_probability(m_tp);
105
106 typedef typename allocator_type::group_adjustor adjustor;
107 adjustor adjust(m_p_c->size());
108
109 try
110 {
111 p_c = new Cntnr(*m_p_c);
112 std::swap(p_c, m_p_c);
113 }
114 catch(__gnu_cxx::forced_error&)
115 {
116 done = false;
117 }
118
119 delete p_c;
120 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
121 return done;
122 }
123
124 PB_DS_CLASS_T_DEC
125 bool
126 PB_DS_CLASS_C_DEC::
127 assignment_operator()
128 {
129 PB_DS_TRACE("assignment operator");
130 bool done = true;
131 Cntnr* p_c = 0;
132 m_alloc.set_probability(m_tp);
133
134 typedef typename allocator_type::group_adjustor adjustor;
135 adjustor adjust(m_p_c->size());
136
137 try
138 {
139 p_c = new Cntnr();
140 *p_c = *m_p_c;
141 std::swap(p_c, m_p_c);
142 }
143 catch(__gnu_cxx::forced_error&)
144 {
145 done = false;
146 }
147
148 delete p_c;
149 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
150 return done;
151 }
152
153 PB_DS_CLASS_T_DEC
154 bool
155 PB_DS_CLASS_C_DEC::
156 it_constructor()
157 {
158 bool done = true;
159 Cntnr* p_c = 0;
160 m_alloc.set_probability(m_tp);
161 typedef typename allocator_type::group_adjustor adjustor;
162 adjustor adjust(m_p_c->size());
163
164 try
165 {
166 switch(get_next_sub_op(3))
167 {
168 case 0:
169 p_c = new Cntnr(m_p_c->get_cmp_fn());
170 m_native_c.clear();
171 break;
172 case 1:
173 p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
174 break;
175 case 2:
176 p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn());
177 break;
178 default:
179 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
180 };
181
182 std::swap(p_c, m_p_c);
183 }
184 catch(__gnu_cxx::forced_error&)
185 {
186 done = false;
187 }
188
189 delete p_c;
190 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
191 return done;
192 }
193
194
195 // Compare.
196 PB_DS_CLASS_T_DEC
197 void
198 PB_DS_CLASS_C_DEC::
199 cmp(const Cntnr& c, const native_type& native, const std::string& callfn)
200 {
201 destructor_printer notify(__FUNCTION__);
202
203 try
204 {
205 m_alloc.set_probability(1);
206
207 const size_t size = c.size();
208 const size_t native_size = native.size();
209 _GLIBCXX_THROW_IF(size != native_size, size << " " << native_size,
210 &c, &native);
211
212 const bool empty = c.empty();
213 const bool native_empty = native.empty();
214 _GLIBCXX_THROW_IF(empty != native_empty, empty << " " << native_empty,
215 &c, &native);
216
217 const size_t it_size = std::distance(c.begin(), c.end());
218 _GLIBCXX_THROW_IF(it_size != size, it_size << " " << size, &c, &native);
219
220 if (!c.empty())
221 {
222 const std::string native_top = native.top();
223 const std::string top = test_traits::native_value(c.top());
224 const bool top_smaller = std::less<std::string>()(top, native_top);
225 const bool top_larger = std::less<std::string>()(native_top, top);
226
227 if (top_smaller || top_larger)
228 _GLIBCXX_THROW_IF(true, top << " " << native_top, &c, &native);
229 }
230 }
231 catch(...)
232 {
233 _GLIBCXX_THROW_IF(true, "call-fn: " + callfn, &c, &native);
234 }
235
236 notify.cancel();
237 }
238
239 // Operators.
240 PB_DS_CLASS_T_DEC
241 void
242 PB_DS_CLASS_C_DEC::
243 operator()()
244 {
245 typedef xml_result_set_regression_formatter formatter_type;
246 formatter_type* p_fmt = 0;
247 if (m_disp)
248 p_fmt = new formatter_type(string_form<Cntnr>::name(),
249 string_form<Cntnr>::desc());
250
251 m_g.init(m_seed);
252 m_alloc.seed(m_seed);
253
254 // The __throw_allocator::_S_label defaults to 0, so to make things
255 // easier and more precise when debugging, start at 1.
256 const size_t starting_label(1);
257
258 try
259 {
260 prog_bar pb(m_n, std::cout, m_disp);
261
262 for (m_i = starting_label; m_i <= m_n; ++m_i)
263 {
264 PB_DS_TRACE("Op #" << m_i);
265
266 // Track allocation from this point only.
267 allocator_type::set_label(m_i);
268 switch(m_i)
269 {
270 case 1:
271 PB_DS_RUN_MTHD(default_constructor);
272 break;
273 case 2:
274 defs();
275 break;
276 case 3:
277 policy_access();
278 break;
279 case 4:
280 it_copy();
281 break;
282 case 5:
283 it_assign();
284 break;
285 default:
286 switch(get_next_op())
287 {
288 case insert_op:
289 PB_DS_RUN_MTHD(push)
290 break;
291 case modify_op:
292 PB_DS_RUN_MTHD(modify)
293 break;
294 case erase_op:
295 switch(get_next_sub_op(3))
296 {
297 case 0:
298 PB_DS_RUN_MTHD(pop)
299 break;
300 case 1:
301 PB_DS_RUN_MTHD(erase_if)
302 break;
303 case 2:
304 PB_DS_RUN_MTHD(erase_it)
305 break;
306 default:
307 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
308 }
309 break;
310 case clear_op:
311 PB_DS_RUN_MTHD(clear)
312 break;
313 case other_op:
314 switch(get_next_sub_op(5))
315 {
316 case 0:
317 swap();
318 break;
319 case 1:
320 PB_DS_RUN_MTHD(copy_constructor)
321 break;
322 case 2:
323 PB_DS_RUN_MTHD(it_constructor)
324 break;
325 case 3:
326 PB_DS_RUN_MTHD(assignment_operator)
327 break;
328 case 4:
329 PB_DS_RUN_MTHD(split_join)
330 break;
331 default:
332 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
333 }
334 break;
335 default:
336 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
337 };
338 }
339 pb.inc();
340 }
341 }
342 catch (...)
343 {
344 std::cerr << "Failed at index " << m_i << std::endl;
345 delete m_p_c;
346 throw;
347 }
348
349 // Clean up, then check for allocation by special label, set above.
350 allocator_type::set_label(0);
351 delete m_p_c;
352
353 try
354 {
355 for (size_t n = starting_label; n <= m_n; ++n)
356 m_alloc.check_allocated(n);
357 }
358 catch (std::logic_error& obj)
359 {
360 // On fail, check_allocated should throw std::logic_error.
361 std::cerr << obj.what() << std::endl;
362 std::cerr << typeid(Cntnr).name() << std::endl;
363 throw;
364 }
365
366 // Reset throw probability.
367 m_alloc.set_probability(0);
368
369 if (m_disp)
370 {
371 std::cout << std::endl;
372 delete p_fmt;
373 }
374 }
375
376 PB_DS_CLASS_T_DEC
377 typename PB_DS_CLASS_C_DEC::op
378 PB_DS_CLASS_C_DEC::
379 get_next_op()
380 {
381 const double prob = m_g.get_prob();
382
383 if (prob < m_ip)
384 return insert_op;
385
386 if (prob < m_ip + m_dp)
387 return modify_op;
388
389 if (prob < m_ip + m_dp + m_ep)
390 return erase_op;
391
392 if (prob < m_ip + m_dp + m_ep + m_cp)
393 return clear_op;
394
395 _GLIBCXX_THROW_IF(prob > 1, prob, m_p_c, &m_native_c);
396 return other_op;
397 }
398
399 PB_DS_CLASS_T_DEC
400 size_t
401 PB_DS_CLASS_C_DEC::
402 get_next_sub_op(size_t max)
403 {
404 const double p = m_g.get_prob();
405 const double delta = 1 / static_cast<double>(max);
406 size_t i = 0;
407 while (true)
408 if (p <= (i + 1) * delta)
409 {
410 _GLIBCXX_THROW_IF(i >= max, i << " " << max, m_p_c, &m_native_c);
411 return i;
412 }
413 else
414 ++i;
415 }
416
417 // Insert.
418 PB_DS_CLASS_T_DEC
419 bool
420 PB_DS_CLASS_C_DEC::
421 push()
422 {
423 PB_DS_TRACE("push");
424 bool done = true;
425 destructor_printer notify(__FUNCTION__);
426
427 try
428 {
429 m_alloc.set_probability(0);
430 value_type v = test_traits::generate_value(m_g, m_m);
431 m_alloc.set_probability(m_tp);
432 const typename cntnr::size_type sz = m_p_c->size();
433 m_p_c->push(v);
434 _GLIBCXX_THROW_IF(sz != m_p_c->size() - 1, sz, m_p_c, &m_native_c);
435 m_native_c.push(test_traits::native_value(v));
436 }
437 catch(__gnu_cxx::forced_error&)
438 {
439 done = false;
440 }
441 catch(...)
442 {
443 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
444 }
445
446 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
447 notify.cancel();
448 return done;
449 }
450
451
452 // Modify.
453 PB_DS_CLASS_T_DEC
454 bool
455 PB_DS_CLASS_C_DEC::
456 modify()
457 {
458 PB_DS_TRACE("modify");
459 destructor_printer notify(__FUNCTION__);
460
461 bool done = true;
462 try
463 {
464 m_alloc.set_probability(0);
465 value_type v = test_traits::generate_value(m_g, m_m);
466
467 m_alloc.set_probability(m_tp);
468 typename cntnr::iterator it = m_p_c->begin();
469 std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
470 if (it != m_p_c->end())
471 {
472 typedef typename test_traits::native_value_type native_value_type;
473 native_value_type native_v = test_traits::native_value(*it);
474 native_value_type new_native_v = test_traits::native_value(v);
475 m_p_c->modify(it, v);
476 m_native_c.modify(native_v, new_native_v);
477 }
478 }
479 catch(__gnu_cxx::forced_error&)
480 {
481 done = false;
482 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
483 }
484
485 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
486 notify.cancel();
487 return done;
488 }
489
490 // Clear.
491 PB_DS_CLASS_T_DEC
492 bool
493 PB_DS_CLASS_C_DEC::
494 clear()
495 {
496 PB_DS_TRACE("clear");
497 m_p_c->clear();
498 m_native_c.clear();
499 return true;
500 }
501
502 // Erase.
503 PB_DS_CLASS_T_DEC
504 bool
505 PB_DS_CLASS_C_DEC::
506 pop()
507 {
508 PB_DS_TRACE("pop");
509 destructor_printer notify(__FUNCTION__);
510
511 bool done = true;
512 try
513 {
514 m_alloc.set_probability(1);
515 if (!m_p_c->empty())
516 {
517 m_p_c->pop();
518 m_native_c.pop();
519 }
520 }
521 catch(__gnu_cxx::forced_error&)
522 {
523 done = false;
524 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
525 }
526
527 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
528 notify.cancel();
529 return done;
530 }
531
532 PB_DS_CLASS_T_DEC
533 bool
534 PB_DS_CLASS_C_DEC::
535 erase_if()
536 {
537 PB_DS_TRACE("erase_if");
538 destructor_printer notify(__FUNCTION__);
539
540 bool done = true;
541 try
542 {
543 typedef
544 typename std::iterator_traits<typename cntnr::iterator>::reference
545 it_const_reference;
546
547 m_alloc.set_probability(1);
548
549 typedef
550 typename test_traits::template erase_if_fn<value_type>
551 erase_if_fn_t;
552
553 const size_t ersd = m_p_c->erase_if(erase_if_fn_t());
554
555 typedef
556 typename test_traits::template erase_if_fn<std::string>
557 native_erase_if_fn_t;
558
559 const size_t native_ersd = m_native_c.erase_if(native_erase_if_fn_t());
560
561 _GLIBCXX_THROW_IF(ersd != native_ersd, ersd << " " << native_ersd,
562 m_p_c, &m_native_c);
563 }
564 catch(__gnu_cxx::forced_error&)
565 {
566 done = false;
567 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
568 }
569
570 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
571 notify.cancel();
572 return done;
573 }
574
575 PB_DS_CLASS_T_DEC
576 bool
577 PB_DS_CLASS_C_DEC::
578 erase_it()
579 {
580 PB_DS_TRACE("erase_it");
581 destructor_printer notify(__FUNCTION__);
582
583 bool done = true;
584 try
585 {
586 m_alloc.set_probability(1);
587 typename cntnr::iterator it = m_p_c->begin();
588 std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
589
590 if (it != m_p_c->end())
591 {
592 m_native_c.erase(*it);
593 m_p_c->erase(it);
594 }
595 }
596 catch(__gnu_cxx::forced_error&)
597 {
598 done = false;
599 _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
600 }
601
602 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
603 notify.cancel();
604 return done;
605 }
606
607 // Defs.
608 PB_DS_CLASS_T_DEC
609 void
610 PB_DS_CLASS_C_DEC::
611 defs()
612 {
613 // General container types.
614 typedef typename Cntnr::size_type test_size_type;
615 typedef typename Cntnr::difference_type difference_type;
616 value_defs();
617 iterator_defs();
618 policy_defs();
619 }
620
621 PB_DS_CLASS_T_DEC
622 void
623 PB_DS_CLASS_C_DEC::
624 value_defs()
625 {
626 typedef typename Cntnr::value_type test_value_type;
627 typedef typename Cntnr::reference test_reference;
628 typedef typename Cntnr::const_reference test_const_reference;
629 typedef typename Cntnr::pointer test_pointer;
630 typedef typename Cntnr::const_pointer test_const_pointer;
631 }
632
633 PB_DS_CLASS_T_DEC
634 void
635 PB_DS_CLASS_C_DEC::
636 ds_defs()
637 {
638 typedef typename Cntnr::container_category test_container_category;
639 }
640
641 PB_DS_CLASS_T_DEC
642 void
643 PB_DS_CLASS_C_DEC::
644 iterator_defs()
645 {
646 typedef typename Cntnr::point_iterator test_point_iterator;
647 typedef typename Cntnr::point_const_iterator const_test_point_iterator;
648 typedef typename Cntnr::iterator test_iterator;
649 typedef typename Cntnr::const_iterator const_test_iterator;
650 }
651
652 PB_DS_CLASS_T_DEC
653 void
654 PB_DS_CLASS_C_DEC::
655 policy_defs()
656 {
657 typedef typename Cntnr::allocator_type test_allocator;
658 typedef typename Cntnr::cmp_fn test_cmp_fn;
659 }
660
661
662 // Policy access.
663 PB_DS_CLASS_T_DEC
664 void
665 PB_DS_CLASS_C_DEC::
666 policy_access()
667 {
668 PB_DS_TRACE("policy_access");
669
670 {
671 typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn();
672 assert(&r_t);
673 }
674
675 {
676 const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn();
677 assert(&r_t);
678 }
679 }
680
681 // Split join.
682 PB_DS_CLASS_T_DEC
683 bool
684 PB_DS_CLASS_C_DEC::
685 split_join()
686 {
687 PB_DS_TRACE("split_join");
688 destructor_printer notify(__FUNCTION__);
689
690 bool done = true;
691 try
692 {
693 m_alloc.set_probability(0);
694 Cntnr lhs(*m_p_c);
695 Cntnr rhs;
696 native_type native_lhs(m_native_c);
697 m_alloc.set_probability(m_tp);
698
699 typedef typename test_traits::template erase_if_fn<value_type> split_fn_t;
700 lhs.split(split_fn_t(), rhs);
701
702 typedef typename test_traits::template erase_if_fn<std::string>
703 native_split_fn_t;
704
705 native_type native_rhs;
706 native_lhs.split(native_split_fn_t(), native_rhs);
707 PB_DS_COND_COMPARE(lhs, native_lhs);
708 PB_DS_COND_COMPARE(rhs, native_rhs);
709
710 m_alloc.set_probability(m_tp);
711
712 if (m_g.get_prob() < 0.5)
713 lhs.swap(rhs);
714 lhs.join(rhs);
715
716 _GLIBCXX_THROW_IF(rhs.size() != 0, rhs.size(), m_p_c, &m_native_c);
717 _GLIBCXX_THROW_IF(!rhs.empty(), rhs.size(), m_p_c, &m_native_c);
718 }
719 catch(__gnu_cxx::forced_error&)
720 {
721 done = false;
722 const bool b = __gnu_pbds::container_traits<cntnr>::split_join_can_throw;
723 _GLIBCXX_THROW_IF(!b, b, m_p_c, &m_native_c);
724 }
725
726 PB_DS_COND_COMPARE(*m_p_c, m_native_c);
727 notify.cancel();
728 return done;
729 }
730
731 // Iterator conversions.
732 PB_DS_CLASS_T_DEC
733 void
734 PB_DS_CLASS_C_DEC::
735 it_copy()
736 {
737 PB_DS_TRACE("it_copy");
738
739 {
740 typename cntnr::iterator it = m_p_c->end();
741 typename cntnr::const_iterator const_it(it);
742 _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
743 _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);
744 }
745
746 {
747 typename cntnr::const_iterator const_it = m_p_c->end();
748 typename cntnr::point_const_iterator const_find_it(const_it);
749 _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
750 _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
751 }
752
753 {
754 typename cntnr::iterator it = m_p_c->end();
755 typename cntnr::point_const_iterator const_find_it1(it);
756 _GLIBCXX_THROW_IF(const_find_it1 != it, "", m_p_c, &m_native_c);
757 _GLIBCXX_THROW_IF(!(const_find_it1 == it), "", m_p_c, &m_native_c);
758
759 typename cntnr::point_iterator find_it1(it);
760 _GLIBCXX_THROW_IF(find_it1 != it, "", m_p_c, &m_native_c);
761 _GLIBCXX_THROW_IF(!(find_it1 == it), "", m_p_c, &m_native_c);
762
763 typename cntnr::point_iterator find_it = m_p_c->end();
764 typename cntnr::point_const_iterator const_find_it(find_it);
765 _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
766 _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
767 }
768 }
769
770 PB_DS_CLASS_T_DEC
771 void
772 PB_DS_CLASS_C_DEC::
773 it_assign()
774 {
775 PB_DS_TRACE("it_assign");
776
777 {
778 typename cntnr::iterator it = m_p_c->end();
779 typename cntnr::const_iterator const_it;
780 const_it = it;
781 _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
782 _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);
783
784 typename cntnr::point_const_iterator const_find_it;
785 const_find_it = it;
786 _GLIBCXX_THROW_IF(const_find_it != it, "", m_p_c, &m_native_c);
787 _GLIBCXX_THROW_IF(!(const_find_it == it), "", m_p_c, &m_native_c);
788
789 typename cntnr::point_iterator find_it;
790 find_it = it;
791 _GLIBCXX_THROW_IF(find_it != it, "", m_p_c, &m_native_c);
792 _GLIBCXX_THROW_IF(!(find_it == it), "", m_p_c, &m_native_c);
793 }
794
795 {
796 typename cntnr::const_iterator const_it = m_p_c->end();
797 typename cntnr::point_const_iterator const_find_it;
798 const_find_it = const_it;
799 _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
800 _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
801 }
802
803 {
804 typename cntnr::point_iterator find_it = m_p_c->end();
805 typename cntnr::point_const_iterator const_find_it;
806 const_find_it = find_it;
807 _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
808 _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
809 }
810 }
811
812
813 // Diagnostics.
814 PB_DS_CLASS_T_DEC
815 void
816 PB_DS_CLASS_C_DEC::
817 print_container(const native_type& cnt, std::ostream& os) const
818 {
819 m_alloc.set_probability(0);
820 native_type cpy(cnt);
821 while (!cpy.empty())
822 {
823 os << cpy.top() << std::endl;
824 cpy.pop();
825 }
826 }
827
828 PB_DS_CLASS_T_DEC
829 void
830 PB_DS_CLASS_C_DEC::
831 print_container(const cntnr& cnt, std::ostream& os) const
832 {
833 typedef typename cntnr::const_iterator const_iterator;
834 m_alloc.set_probability(0);
835 for (const_iterator it = cnt.begin(); it != cnt.end(); ++it)
836 os << *it << std::endl;
837 }
838
839 #endif