summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc
blob: 11453855993589594bb051a1aaada9f0d6f0eb30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
// -*- C++ -*-

// Copyright (C) 2005-2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 3, or (at your option) any later
// version.

// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.


// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.

// Permission to use, copy, modify, sell, and distribute this software
// is hereby granted without fee, provided that the above copyright
// notice appears in all copies, and that both that copyright notice
// and this permission notice appear in supporting documentation. None
// of the above authors, nor IBM Haifa Research Laboratories, make any
// representation about the suitability of this software for any
// purpose. It is provided "as is" without express or implied
// warranty.

/**
 * @file container_rand_regression_test.tcc
 * Contains a random regression test for a specific container type.
 */

#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC

  // Constructor, copy constructor, assignment and destructor.
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
container_rand_regression_test(unsigned long seed, size_t n, size_t m,
			       double tp, double ip, double dp, double ep,
			       double cp, double mp, bool disp)
: m_seed(seed == 0 ? twister_rand_gen::get_time_determined_seed(): seed),
  m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep), m_cp(cp),
  m_mp(mp), m_disp(disp), m_p_c(0)
{ }

PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
~container_rand_regression_test()
{ }

PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
default_constructor()
{
  PB_DS_TRACE("default_constructor");
  bool done = true;
  m_alloc.set_probability(m_tp);

  try
    {
      m_p_c = new Cntnr;
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
    }

  if (m_p_c)
    PB_DS_COND_COMPARE(*m_p_c, m_native_c);

  return done;
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
swap()
{
  PB_DS_TRACE("swap");
  m_alloc.set_probability(0);
  Cntnr* p_c = new Cntnr;
  m_alloc.set_probability(1);
  p_c->swap(*m_p_c);
  std::swap(p_c, m_p_c);
  delete p_c;
  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
}

PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
copy_constructor()
{
  PB_DS_TRACE("copy_constructor");
  bool done = true;
  Cntnr* p_c = 0;
  m_alloc.set_probability(m_tp);

  typedef typename allocator_type::group_adjustor adjustor;
  adjustor adjust(m_p_c->size());

  try
    {
      p_c = new Cntnr(*m_p_c);
      std::swap(p_c, m_p_c);
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
    }

  delete p_c;
  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  return done;
}

PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
assignment_operator()
{
  PB_DS_TRACE("assignment operator");
  bool done = true;
  Cntnr* p_c = 0;
  m_alloc.set_probability(m_tp);

  typedef typename allocator_type::group_adjustor adjustor;
  adjustor adjust(m_p_c->size());

  try
    {
      p_c = new Cntnr();
      *p_c = *m_p_c;
      std::swap(p_c, m_p_c);
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
    }

  delete p_c;
  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  return done;
}

PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
it_constructor()
{
  bool done = true;
  Cntnr* p_c = 0;
  m_alloc.set_probability(m_tp);
  typedef typename allocator_type::group_adjustor adjustor;
  adjustor adjust(m_p_c->size());

  try
    {
      switch(get_next_sub_op(3))
        {
        case 0:
	  p_c = new Cntnr(m_p_c->get_cmp_fn());
	  m_native_c.clear();
	  break;
        case 1:
	  p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
	  break;
        case 2:
	  p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn());
	  break;
        default:
	  _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
        };

      std::swap(p_c, m_p_c);
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
    }

  delete p_c;
  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  return done;
}


  // Compare.
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
cmp(const Cntnr& c, const native_type& native, const std::string& callfn)
{
  destructor_printer notify(__FUNCTION__);

  try
    {
      m_alloc.set_probability(1);

      const size_t size = c.size();
      const size_t native_size = native.size();
      _GLIBCXX_THROW_IF(size != native_size, size << " " << native_size,
			&c, &native);

      const bool empty = c.empty();
      const bool native_empty = native.empty();
      _GLIBCXX_THROW_IF(empty != native_empty, empty << " " << native_empty,
			&c, &native);

      const size_t it_size = std::distance(c.begin(), c.end());
      _GLIBCXX_THROW_IF(it_size != size, it_size << " " << size, &c, &native);

      if (!c.empty())
	{
	  const std::string native_top = native.top();
	  const std::string top = test_traits::native_value(c.top());
	  const bool top_smaller = std::less<std::string>()(top, native_top);
	  const bool top_larger = std::less<std::string>()(native_top, top);

	  if (top_smaller || top_larger)
	    _GLIBCXX_THROW_IF(true, top << " " << native_top, &c, &native);
	}
    }
  catch(...)
    {
      _GLIBCXX_THROW_IF(true, "call-fn: " + callfn, &c, &native);
    }

  notify.cancel();
}

  // Operators.
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
operator()()
{
  typedef xml_result_set_regression_formatter formatter_type;
  formatter_type* p_fmt = 0;
  if (m_disp)
    p_fmt = new formatter_type(string_form<Cntnr>::name(),
			       string_form<Cntnr>::desc());

  m_g.init(m_seed);
  m_alloc.seed(m_seed);

  // The __throw_allocator::_S_label defaults to 0, so to make things
  // easier and more precise when debugging, start at 1.
  const size_t starting_label(1);

  try
    {
      prog_bar pb(m_n, std::cout, m_disp);

      for (m_i = starting_label; m_i <= m_n; ++m_i)
        {
	  PB_DS_TRACE("Op #" << m_i);

	  // Track allocation from this point only.
	  allocator_type::set_label(m_i);
	  switch(m_i)
            {
            case 1:
	      PB_DS_RUN_MTHD(default_constructor);
	      break;
            case 2:
	      defs();
	      break;
            case 3:
	      policy_access();
	      break;
            case 4:
	      it_copy();
	      break;
            case 5:
	      it_assign();
	      break;
            default:
	      switch(get_next_op())
                {
                case insert_op:
		  PB_DS_RUN_MTHD(push)
                    break;
                case modify_op:
		  PB_DS_RUN_MTHD(modify)
                    break;
                case erase_op:
		  switch(get_next_sub_op(3))
                    {
                    case 0:
		      PB_DS_RUN_MTHD(pop)
                        break;
                    case 1:
		      PB_DS_RUN_MTHD(erase_if)
                        break;
                    case 2:
		      PB_DS_RUN_MTHD(erase_it)
                        break;
                    default:
		      _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
                    }
		  break;
                case clear_op:
		  PB_DS_RUN_MTHD(clear)
                    break;
                case other_op:
		  switch(get_next_sub_op(5))
                    {
                    case 0:
		      swap();
		      break;
                    case 1:
		      PB_DS_RUN_MTHD(copy_constructor)
                        break;
                    case 2:
		      PB_DS_RUN_MTHD(it_constructor)
                        break;
                    case 3:
		      PB_DS_RUN_MTHD(assignment_operator)
                        break;
                    case 4:
		      PB_DS_RUN_MTHD(split_join)
                        break;
                    default:
		      _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
                    }
		  break;
                default:
		  _GLIBCXX_THROW_IF(true, "", m_p_c,  &m_native_c);
                };
            }
	  pb.inc();
        }
    }
  catch (...)
    {
      std::cerr << "Failed at index " << m_i << std::endl;
      delete m_p_c;
      throw;
    }

  // Clean up, then check for allocation by special label, set above.
  allocator_type::set_label(0);
  delete m_p_c;

  try
    {
      for (size_t n = starting_label; n <= m_n; ++n)
	m_alloc.check(n);
    }
  catch (std::logic_error& obj)
    {
      // On fail, check should throw std::logic_error.
      std::cerr << obj.what() << std::endl;
      std::cerr << typeid(Cntnr).name() << std::endl;
      throw;
    }

  // Reset throw probability.
  m_alloc.set_probability(0);

  if (m_disp)
    {
      std::cout << std::endl;
      delete p_fmt;
    }
}

PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::op
PB_DS_CLASS_C_DEC::
get_next_op()
{
  const double prob = m_g.get_prob();

  if (prob < m_ip)
    return insert_op;

  if (prob < m_ip + m_dp)
    return modify_op;

  if (prob < m_ip + m_dp + m_ep)
    return erase_op;

  if (prob < m_ip + m_dp + m_ep + m_cp)
    return clear_op;

  _GLIBCXX_THROW_IF(prob > 1, prob, m_p_c, &m_native_c);
  return other_op;
}

PB_DS_CLASS_T_DEC
size_t
PB_DS_CLASS_C_DEC::
get_next_sub_op(size_t max)
{
  const double p = m_g.get_prob();
  const double delta = 1 / static_cast<double>(max);
  size_t i = 0;
  while (true)
    if (p <= (i + 1) * delta)
      {
	_GLIBCXX_THROW_IF(i >= max, i << " " << max, m_p_c, &m_native_c);
	return i;
      }
    else
      ++i;
}

  // Insert.
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
push()
{
  PB_DS_TRACE("push");
  bool done = true;
  destructor_printer notify(__FUNCTION__);

    try
      {
        m_alloc.set_probability(0);
        value_type v = test_traits::generate_value(m_g, m_m);
        m_alloc.set_probability(m_tp);
        const typename cntnr::size_type sz = m_p_c->size();
        m_p_c->push(v);
        _GLIBCXX_THROW_IF(sz != m_p_c->size() - 1, sz, m_p_c, &m_native_c);
        m_native_c.push(test_traits::native_value(v));
      }
    catch(__gnu_cxx::forced_error&)
      {
        done = false;
      }
    catch(...)
      {
        _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
      }

  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  notify.cancel();
  return done;
}


  // Modify.
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
modify()
{
  PB_DS_TRACE("modify");
  destructor_printer notify(__FUNCTION__);

  bool done = true;
  try
    {
      m_alloc.set_probability(0);
      value_type v = test_traits::generate_value(m_g, m_m);

      m_alloc.set_probability(m_tp);
      typename cntnr::iterator it = m_p_c->begin();
      std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
      if (it != m_p_c->end())
	{
	  typedef typename test_traits::native_value_type native_value_type;
	  native_value_type native_v = test_traits::native_value(*it);
	  native_value_type new_native_v = test_traits::native_value(v);
	  m_p_c->modify(it, v);
	  m_native_c.modify(native_v, new_native_v);
	}
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
      _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
    }

  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  notify.cancel();
  return done;
}

  // Clear.
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
clear()
{
  PB_DS_TRACE("clear");
  m_p_c->clear();
  m_native_c.clear();
  return true;
}

  // Erase.
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
pop()
{
  PB_DS_TRACE("pop");
  destructor_printer notify(__FUNCTION__);

  bool done = true;
  try
    {
      m_alloc.set_probability(1);
      if (!m_p_c->empty())
        {
	  m_p_c->pop();
	  m_native_c.pop();
        }
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
      _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
    }

  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  notify.cancel();
  return done;
}

PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
erase_if()
{
  PB_DS_TRACE("erase_if");
  destructor_printer notify(__FUNCTION__);

  bool done = true;
  try
    {
      typedef
	typename std::iterator_traits<typename cntnr::iterator>::reference
	it_const_reference;

      m_alloc.set_probability(1);

      typedef
	typename test_traits::template erase_if_fn<value_type>
	erase_if_fn_t;

      const size_t ersd = m_p_c->erase_if(erase_if_fn_t());

      typedef
	typename test_traits::template erase_if_fn<std::string>
	native_erase_if_fn_t;

      const size_t native_ersd = m_native_c.erase_if(native_erase_if_fn_t());

      _GLIBCXX_THROW_IF(ersd != native_ersd, ersd << " " << native_ersd,
			m_p_c, &m_native_c);
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
      _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
    }

  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  notify.cancel();
  return done;
}

PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
erase_it()
{
  PB_DS_TRACE("erase_it");
  destructor_printer notify(__FUNCTION__);

  bool done = true;
  try
    {
      m_alloc.set_probability(1);
      typename cntnr::iterator it = m_p_c->begin();
      std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));

      if (it != m_p_c->end())
	{
	  m_native_c.erase(*it);
	  m_p_c->erase(it);
	}
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
      _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
    }

  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  notify.cancel();
  return done;
}

  // Defs.
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
defs()
{
  // General container types.
  typedef typename Cntnr::size_type test_size_type;
  typedef typename Cntnr::difference_type difference_type;
  value_defs();
  iterator_defs();
  policy_defs();
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
value_defs()
{
  typedef typename Cntnr::value_type test_value_type;
  typedef typename Cntnr::reference test_reference;
  typedef typename Cntnr::const_reference test_const_reference;
  typedef typename Cntnr::pointer test_pointer;
  typedef typename Cntnr::const_pointer test_const_pointer;
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
ds_defs()
{
  typedef typename Cntnr::container_category test_container_category;
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
iterator_defs()
{
  typedef typename Cntnr::point_iterator test_point_iterator;
  typedef typename Cntnr::point_const_iterator const_test_point_iterator;
  typedef typename Cntnr::iterator test_iterator;
  typedef typename Cntnr::const_iterator const_test_iterator;
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
policy_defs()
{
  typedef typename Cntnr::allocator_type test_allocator;
  typedef typename Cntnr::cmp_fn test_cmp_fn;
}


// Policy access.
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
policy_access()
{
  PB_DS_TRACE("policy_access");

  {
    typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn();
    assert(&r_t);
  }

  {
    const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn();
    assert(&r_t);
  }
}

// Split join.
PB_DS_CLASS_T_DEC
bool
PB_DS_CLASS_C_DEC::
split_join()
{
  PB_DS_TRACE("split_join");
  destructor_printer notify(__FUNCTION__);

  bool done = true;
  try
    {
      m_alloc.set_probability(0);
      Cntnr lhs(*m_p_c);
      Cntnr rhs;
      native_type native_lhs(m_native_c);
      m_alloc.set_probability(m_tp);

      typedef typename test_traits::template erase_if_fn<value_type> split_fn_t;
      lhs.split(split_fn_t(), rhs);

      typedef typename test_traits::template erase_if_fn<std::string>
	native_split_fn_t;

      native_type native_rhs;
      native_lhs.split(native_split_fn_t(), native_rhs);
      PB_DS_COND_COMPARE(lhs, native_lhs);
      PB_DS_COND_COMPARE(rhs, native_rhs);

      m_alloc.set_probability(m_tp);

      if (m_g.get_prob() < 0.5)
	lhs.swap(rhs);
      lhs.join(rhs);

      _GLIBCXX_THROW_IF(rhs.size() != 0, rhs.size(), m_p_c, &m_native_c);
      _GLIBCXX_THROW_IF(!rhs.empty(), rhs.size(), m_p_c, &m_native_c);
    }
  catch(__gnu_cxx::forced_error&)
    {
      done = false;
      const bool b = __gnu_pbds::container_traits<cntnr>::split_join_can_throw;
      _GLIBCXX_THROW_IF(!b, b, m_p_c, &m_native_c);
    }

  PB_DS_COND_COMPARE(*m_p_c, m_native_c);
  notify.cancel();
  return done;
}

// Iterator conversions.
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
it_copy()
{
  PB_DS_TRACE("it_copy");

  {
    typename cntnr::iterator it = m_p_c->end();
    typename cntnr::const_iterator const_it(it);
    _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);
  }

  {
    typename cntnr::const_iterator const_it = m_p_c->end();
    typename cntnr::point_const_iterator const_find_it(const_it);
    _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
  }

  {
    typename cntnr::iterator it = m_p_c->end();
    typename cntnr::point_const_iterator const_find_it1(it);
    _GLIBCXX_THROW_IF(const_find_it1 != it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(const_find_it1 == it), "", m_p_c, &m_native_c);

    typename cntnr::point_iterator find_it1(it);
    _GLIBCXX_THROW_IF(find_it1 != it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(find_it1 == it), "", m_p_c, &m_native_c);

    typename cntnr::point_iterator find_it = m_p_c->end();
    typename cntnr::point_const_iterator const_find_it(find_it);
    _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
  }
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
it_assign()
{
  PB_DS_TRACE("it_assign");

  {
    typename cntnr::iterator it = m_p_c->end();
    typename cntnr::const_iterator const_it;
    const_it = it;
    _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);

    typename cntnr::point_const_iterator const_find_it;
    const_find_it = it;
    _GLIBCXX_THROW_IF(const_find_it != it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(const_find_it == it), "", m_p_c, &m_native_c);

    typename cntnr::point_iterator find_it;
    find_it = it;
    _GLIBCXX_THROW_IF(find_it != it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(find_it == it), "", m_p_c, &m_native_c);
  }

  {
    typename cntnr::const_iterator const_it = m_p_c->end();
    typename cntnr::point_const_iterator const_find_it;
    const_find_it = const_it;
    _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
  }

  {
    typename cntnr::point_iterator find_it = m_p_c->end();
    typename cntnr::point_const_iterator const_find_it;
    const_find_it = find_it;
    _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
    _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
  }
}


// Diagnostics.
PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
print_container(const native_type& cnt, std::ostream& os) const
{
  m_alloc.set_probability(0);
  native_type cpy(cnt);
  while (!cpy.empty())
    {
      os << cpy.top() << std::endl;
      cpy.pop();
    }
}

PB_DS_CLASS_T_DEC
void
PB_DS_CLASS_C_DEC::
print_container(const cntnr& cnt, std::ostream& os) const
{
  typedef typename cntnr::const_iterator const_iterator;
  m_alloc.set_probability(0);
  for (const_iterator it = cnt.begin(); it != cnt.end(); ++it)
    os << *it << std::endl;
}

#endif