Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
rw_alg_test.h
Go to the documentation of this file.
1
29#ifndef RW_ALG_TEST_H_INCLUDED
30#define RW_ALG_TEST_H_INCLUDED
31
32#include <rw/_iterbase.h> // for iterator
33
34#include <rw_testdefs.h>
35
36// generate a unique sequential number starting from 0
38
39// generate numbers in the sequence 0, 0, 1, 1, 2, 2, 3, 3, etc...
41
42// generate a sequence of subsequences (i.e., 0, 1, 2, 3, 4, 0, 1, 2, etc...)
44
45// wrapper around a (possibly) extern "C" int rand()
46// extern "C++"
48
49
50// computes an integral log2
51_TEST_EXPORT unsigned ilog2 (_RWSTD_SIZE_T);
52
53// computes an integral log10
54_TEST_EXPORT unsigned ilog10 (_RWSTD_SIZE_T);
55
56
57template <class InputIterator, class Predicate>
58inline bool
60{
61 if (first == last)
62 return true;
63
64 for (InputIterator prev (first); ++first != last; prev = first) {
65 if (pred (*first, *prev))
66 return false;
67 }
68
69 return true;
70}
71
72// returns true iff a sequence of (not necessarily unique) values
73// is sorted in an ascending order
74template <class InputIterator>
76{
77 if (first == last)
78 return true;
79
80 for (InputIterator prev (first); ++first != last; prev = first) {
81 if (*first < *prev)
82 return false;
83 }
84
85 return true;
86}
87
88
89// returns true iff a sequence of (not necessarily unique) values
90// is sorted in a descending order
91template <class InputIterator>
93{
94 if (first == last)
95 return true;
96
97 for (InputIterator prev (first); ++first != last; prev = first) {
98 if (*prev < *first)
99 return false;
100 }
101
102 return true;
103}
104
105
107// type used to exercise that algorithms do not apply operators
108// to function objects the latter are not required to define
110{
111 static conv_to_bool make (bool val) {
112 return conv_to_bool (val);
113 }
114
115#if !defined (_MSC_VER) || _MSC_VER > 1300
116 // unique pointer not compatible with any other
117 typedef bool conv_to_bool::*UniquePtr;
118
119 // strictly convertible to a Boolean value testable
120 // in the controlling expression of the if statement
121 // as required in 25, p7
122 operator UniquePtr () const {
123 return val_ ? &conv_to_bool::val_ : UniquePtr (0);
124 }
125#else
126 typedef const void* UniquePtr;
127
128 operator UniquePtr () const {
129 return val_ ? &val_ : UniquePtr (0);
130 }
131#endif
132
133private:
134 // not (publicly) Default-Constructible
135 conv_to_bool (bool val): val_ (val) { }
136
137 void operator= (conv_to_bool); // not Assignable
138 void operator!() const; // not defined
139
140 bool val_;
141};
142
143// not defined
144void operator&& (const conv_to_bool&, bool);
145void operator&& (bool, const conv_to_bool&);
146void operator|| (const conv_to_bool&, bool);
147void operator|| (bool, const conv_to_bool&);
148
149// element-type prototypes to exercise container requirements
150
151
152// meets requirements listed at 25, p7
153template <class T>
154struct predicate {
155 conv_to_bool operator() (const T &a) const {
157 return conv_to_bool::make (true);
158 }
159};
160
161
162// meets requirements listed at 25, p8
163template <class T>
165 conv_to_bool operator() (const T &a, const T &b) const {
168 return conv_to_bool::make (true);
169 }
170};
171
172
173// meets requirements listed at 25.2.3, p2
174template <class T>
175struct func {
178
181 _RWSTD_CONST_CAST (func*, this)->dummy);
182 }
183
184private:
185 char dummy;
186};
187
188
189// meets requirements listed at 25.2.3, p2
190template <class T>
194
196 const argument_type&) const {
198 _RWSTD_CONST_CAST (binary_func*, this)->dummy);
199 }
200
201private:
202 char dummy;
203};
204
205
206// a base-class to extend the requirements classes from
207
208enum { no_ctor = 0, def_ctor = 1, cpy_ctor = 2 };
209
210template <int c = no_ctor>
211struct base;
212
213
214template<>
216{
217private:
218 // struct s added to prevent gcc warning: base<no_ctor> has a private
219 // constructor and no friends
220 struct s { };
221 friend struct s;
222
223 base ();
224 base (const base&);
225 void operator= (base&);
226};
227
228
229template<>
231{
232 base () : unused (0) { }
233
234private:
235
236 void operator= (base&);
237 base (const base&);
238
239 // unused member prevents bogus HP aCC warnings (see Onyx #23561)
240 int unused;
241};
242
243
244template<>
246{
247 // explicitly specifying redundant template parameters to work
248 // around a SunPro 5.2 bug (see Onyx #24260)
249 base (const base<cpy_ctor> &rhs): unused (rhs.unused) { }
250
251private:
252
253 base ();
254 void operator= (base&);
255
256 // unused member prevents bogus HP aCC warnings (see Onyx #23561)
257 int unused;
258};
259
260
261template<>
263{
264 base (): unused (0) { }
265
266 // explicitly specifying redundant template parameters to work
267 // around a SunPro 5.2 bug (see Onyx #24260)
268 base (const base<(def_ctor | cpy_ctor)> &rhs): unused (rhs.unused) { }
269
270private:
271
272 void operator= (base&);
273
274 // unused member prevents bogus HP aCC warnings (see Onyx #23561)
275 int unused;
276};
277
278
279template <class T>
280struct eq_comp: T { };
281
282
283template <class T>
284inline bool operator== (const eq_comp<T>&, const eq_comp<T>&)
285{
286 return true;
287}
288
289
290template <class T>
291struct lt_comp: T { };
292
293
294template <class T>
295inline bool operator< (const lt_comp<T>&, const lt_comp<T>&)
296{
297 return true;
298}
299
300
301// assignment
302
303template <class T>
304struct assign : T
305{
307 unused = rhs.unused;
308 return *this;
309 }
310private:
311 // unused member prevents bogus HP aCC warnings (see Onyx #23561)
312 int unused;
313};
314
315
316// conversion structs
317
318// struct split into 2 to eliminate the following g++ 2.95.2 warning:
319// warning: choosing `convert<T>::operator U&()' over
320// `convert<T>::operator const U&() const'
321
322template <class T, class U>
323struct cvt : T
324{
325 operator U& () {
326 return _RWSTD_REINTERPRET_CAST (U&, *this);
327 }
328};
329
330
331template <class T, class U>
332struct const_cvt : T
333{
334 operator const U& () const {
335 return _RWSTD_REINTERPRET_CAST (const U&, *this);
336 }
337};
338
339
341// Size template argument to fill_n(), generate_n(), and search_n()
342template <class IntegralT>
343struct Size
344{
345 typedef IntegralT IntegralType;
346
347 // dummy argument provided to prevent Size from being constructible
348 // by conversion from IntegralT
349 Size (IntegralT val, int /* dummy */ )
350 : val_ (val) { /* empty */ }
351
352 // Size must be convertible to an integral type
353 operator IntegralT () const { return val_; }
354
355private:
356
357 void operator= (const Size&); // not Assignable
358
359 IntegralT val_;
360};
361
362
364#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
365
366struct DummyBase { };
367
368# define ITER_BASE(ign1, ign2, ign3, ign4, ign5) DummyBase
369#else // if defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
370 // when partial specialization isn't supported
371# define ITER_BASE(Cat, T, Dist, Ptr, Ref) \
372 std::iterator<Cat, T, Dist, Ptr, Ref >
373#endif // _RWSTD_NO_CLASS_PARTIAL_SPEC
374
375
376// satisfies the requirements in 24.1.1 [lib.input.iterators]
377template <class T>
378struct InputIter: ITER_BASE (std::input_iterator_tag, T, int, T*, T&)
379{
380 typedef T value_type;
383 typedef _RWSTD_PTRDIFF_T difference_type;
384 typedef std::input_iterator_tag iterator_category;
385
386 // body shared by all copies of the same InputIter specialization
387 // to detect algorithms that pass through the same interator more
388 // than once (disallowed by 24.1.1, p3)
389 struct Shared {
393 int ref_;
394
396 const value_type *beg,
397 const value_type *end)
398 : cur_ (cur), beg_ (beg), end_ (end), ref_ (1) {
399 RW_ASSERT (beg_ <= cur_ && cur_ <= end_);
400 }
401
403 cur_ = beg_ = end_ = 0;
404 ref_ = -1;
405 }
406
407 private:
408 Shared (const Shared&); // not defined
409 void operator= (const Shared&); // not defined
410
411 };
412
413 // InputIterators are not default constructible
414 InputIter (const value_type* /* current */,
415 const value_type* /* begin */,
416 const value_type* /* end */);
417
418 InputIter (const InputIter&);
419
420 ~InputIter ();
421
422 InputIter& operator= (const InputIter&);
423
424 bool operator== (const InputIter&) const;
425
426 bool operator!= (const InputIter &rhs) const {
427 return !(*this == rhs);
428 }
429
430 // returning const-reference rather than a value in order
431 // not to impose the CopyConstructible requirement on T
432 // and to disallow constructs like *InputIter<T>() = T()
433 const value_type& operator* () const {
434 RW_ASSERT (*this == *this); // assert *this is valid
435 RW_ASSERT (cur_ < ptr_->end_); // assert *this is dereferenceable
436 return *cur_;
437 }
438
439 _RWSTD_OPERATOR_ARROW (const value_type* operator-> () const);
440
441 InputIter& operator++ () {
442 RW_ASSERT (*this == *this); // assert *this is valid
443 RW_ASSERT (cur_ < ptr_->end_); // assert *this is not past the end
444
445 ptr_->cur_ = ++cur_;
446
447 return *this;
448 }
449
450 InputIter operator++ (int) {
451 return ++*this;
452 }
453
454// private:
456 const value_type *cur_; // past-the-end
457};
458
459
460// "large" member functions outlined to prevent gcc -Winline warnings
461
462template <class T>
464InputIter (const value_type *cur,
465 const value_type *beg,
466 const value_type *end)
467 : ptr_ (new Shared (cur, beg, end)), cur_ (cur)
468{
469 // empty
470}
471
472
473template <class T>
475InputIter (const InputIter &rhs)
476 : ptr_ (rhs.ptr_), cur_ (rhs.cur_)
477{
478 RW_ASSERT (0 != ptr_);
479 ++ptr_->ref_;
480}
481
482
483template <class T>
485~InputIter ()
486{
487 RW_ASSERT (0 != ptr_);
488
489 if (0 == --ptr_->ref_) // decrement the reference count
490 delete ptr_;
491
492 ptr_ = 0;
493 cur_ = 0;
494}
495
496
497template <class T>
501{
502 RW_ASSERT (rhs == rhs); // assert `rhs' is valid
503
504 RW_ASSERT (0 != ptr_);
505 if (0 == --ptr_->ref_)
506 delete ptr_;
507
508 ptr_ = rhs.ptr_;
509
510 RW_ASSERT (0 != ptr_);
511 ++ptr_->ref_;
512
513 cur_ = rhs.cur_;
514
515 return *this;
516}
517
518
519template <class T>
520bool
522operator== (const InputIter &rhs) const
523{
524 // assert that both arguments are in the domain of operator==()
525 // i.e., that no copy of *this or `rhs' has been incremented
526 // and that no copy passed through this value of the iterator
527
528 RW_ASSERT (0 != ptr_);
529 RW_ASSERT (cur_ == ptr_->cur_);
530
531 RW_ASSERT (0 != rhs.ptr_);
532 RW_ASSERT (rhs.cur_ == rhs.ptr_->cur_);
533
534 return cur_ == rhs.cur_;
535}
536
537
539// satisfies the requirements in 24.1.2 [lib.output.iterators]
540template <class T>
541struct OutputIter: ITER_BASE (std::output_iterator_tag, T, int, T*, T&)
542{
543 typedef T value_type;
546 typedef _RWSTD_PTRDIFF_T difference_type;
547 typedef std::output_iterator_tag iterator_category;
548
549 // body shared by all copies of the same OutputIter specialization
550 // to detect algorithms that pass through the same interator more
551 // than once (disallowed by 24.1.2, p2)
552 struct Shared {
557 int ref_;
558
560 : cur_ (cur), assign_ (cur), begin_ (cur), end_ (end), ref_ (1) { }
561
563 begin_ = end_ = cur_ = assign_ = 0;
564 ref_ = -1;
565 }
566
567 private:
568 Shared (const Shared&); // not defined
569 void operator= (const Shared&); // not defined
570
571 };
572
573 // class whose objects are returned from OutputIter::operator*
574 // to detect multiple assignments (disallowed by 24.1.2, p2)
575 class Proxy {
576 friend struct OutputIter;
577
578 Shared* const ptr_;
579
580 Proxy (Shared *ptr): ptr_ (ptr) { }
581
582 public:
583 void operator= (const value_type &rhs) {
584 RW_ASSERT (0 != ptr_);
585
586 // verify that the iterator is in the valid range
587 RW_ASSERT (ptr_->cur_ >= ptr_->begin_ && ptr_->cur_ <= ptr_->end_);
588
589 // verify that the assignment point is the same as the current
590 // position `cur' within the sequence or immediately before it
591 // (in order to allow the expression: *it++ = val)
592 RW_ASSERT ( ptr_->assign_ == ptr_->cur_
593 || ptr_->assign_ + 1 == ptr_->cur_);
594
595 // assign and increment the assignment point
596 *ptr_->assign_++ = rhs;
597 }
598 };
599
600 // OutputIterators are not default constructible
602 const value_type *,
603 const value_type *end)
604 : ptr_ (new Shared (cur, end)), cur_ (cur) { }
605
607 : ptr_ (rhs.ptr_), cur_ (rhs.cur_) {
608 ++ptr_->ref_; // increment the reference count
609 }
610
611 ~OutputIter ();
612
613 OutputIter& operator= (const OutputIter&);
614
615 void operator= (const value_type &rhs) const {
616 **this = rhs;
617 }
618
619 // return a proxy in order to detect multiple assignments
620 // through the iterator (disallowed by 24.1.2, p2))
622 RW_ASSERT (0 != ptr_);
624
625 return Proxy (ptr_);
626 }
627
628 _RWSTD_OPERATOR_ARROW (pointer operator-> () const);
629
630 OutputIter& operator++ () {
631 RW_ASSERT (cur_ == ptr_->cur_);
633 cur_ = ++ptr_->cur_;
634 return *this;
635 }
636
637 // returning a const value rather than a modifiable value
638 // in order to verify the requirement in row 5 of Table 73
639 const OutputIter operator++ (int) {
640 OutputIter tmp (*this);
641 return ++*this, tmp;
642 }
643
644// private:
647};
648
649
650// "large" member functions outlined to prevent gcc -Winline warnings
651
652template <class T>
655{
656 RW_ASSERT (0 != ptr_);
657
658 if (0 == --ptr_->ref_) // decrement the reference count
659 delete ptr_;
660
661 ptr_ = 0;
662 cur_ = 0;
663}
664
665
666template <class T>
670{
671 RW_ASSERT (0 != ptr_);
672
673 if (0 == --ptr_->ref_)
674 delete ptr_;
675
676 ptr_ = rhs.ptr_;
677 ++ptr_->ref_;
678
679 cur_ = rhs.cur_;
680
681 return *this;
682}
683
684
686// satisfies the requirements in 24.1.3 [lib.forward.iterators]
687template <class T>
688struct FwdIter: ITER_BASE (std::forward_iterator_tag, T, int, T*, T&)
689{
690 typedef T value_type;
693 typedef _RWSTD_PTRDIFF_T difference_type;
694 typedef std::forward_iterator_tag iterator_category;
695
696 FwdIter (): cur_ (0), end_ (0) { }
697
699 const value_type *,
700 const value_type *end)
701 : cur_ (cur), end_ (end) { }
702
704 : cur_ (rhs.cur_), end_ (rhs.end_) { }
705
707 end_ = cur_ = 0;
708 }
709
711 cur_ = rhs.cur_;
712 end_ = rhs.end_;
713 return *this;
714 }
715
716 bool operator== (const FwdIter &rhs) const {
717 RW_ASSERT (cur_ != 0);
718 return cur_ == rhs.cur_;
719 }
720
721 bool operator!= (const FwdIter &rhs) const {
722 return !(*this == rhs);
723 }
724
726 RW_ASSERT (cur_ != 0 && cur_ != end_);
727 return *cur_;
728 }
729
730 _RWSTD_OPERATOR_ARROW (pointer operator-> () const);
731
733 RW_ASSERT (cur_ != 0 && cur_ != end_);
734 return ++cur_, *this;
735 }
736
738 FwdIter tmp (*this);
739 return ++*this, tmp;
740 }
741
742// private:
743 pointer cur_; // pointer to current element
744 const value_type *end_; // past-the-end
745};
746
747
748template <class T>
749struct ConstFwdIter: FwdIter<const T>
750{
751 typedef T value_type;
753
755
757 const value_type *begin,
758 const value_type *end)
759 : Base (cur, begin, end) { }
760
761 const value_type& operator* () const {
762 return Base::operator* ();
763 }
764
765 _RWSTD_OPERATOR_ARROW (const value_type* operator-> () const);
766};
767
768
770// satisfies the requirements in 24.1.4 [lib.bidirectional.iterators]
771template <class T>
772struct BidirIter: ITER_BASE (std::bidirectional_iterator_tag, T, int, T*, T&)
773{
774 typedef T value_type;
777 typedef _RWSTD_PTRDIFF_T difference_type;
778 typedef std::bidirectional_iterator_tag iterator_category;
779
780 BidirIter (): cur_ (0), begin_ (0), end_ (0) { }
781
783 const value_type *begin,
784 const value_type *end)
785 : cur_ (cur), begin_ (begin), end_ (end) { }
786
788 : cur_ (rhs.cur_), begin_ (rhs.begin_), end_ (rhs.end_) { }
789
791 begin_ = end_ = cur_ = 0;
792 }
793
795 cur_ = rhs.cur_;
796 end_ = rhs.end_;
797 return *this;
798 }
799
800 bool operator== (const BidirIter &rhs) const {
801 RW_ASSERT (cur_ != 0 && rhs.cur_ != 0);
802 return cur_ == rhs.cur_;
803 }
804
805 bool operator!= (const BidirIter &rhs) const {
806 return !(*this == rhs);
807 }
808
810 RW_ASSERT (cur_ != 0 && cur_ != end_);
811 return *cur_;
812 }
813
814 _RWSTD_OPERATOR_ARROW (pointer operator-> () const);
815
817 RW_ASSERT (cur_ != 0 && cur_ != end_);
818 return ++cur_, *this;
819 }
820
822 BidirIter tmp (*this);
823 return ++*this, tmp;
824 }
825
827 RW_ASSERT (cur_ != 0 && cur_ != begin_);
828 return --cur_, *this;
829 }
830
832 BidirIter tmp (*this);
833 return --*this, tmp;
834 }
835
836// private:
837 pointer cur_; // pointer to current element
838 const value_type *begin_; // first in range
839 const value_type *end_; // past-the-end
840};
841
842
843template <class T>
844struct ConstBidirIter: BidirIter<const T>
845{
846 typedef T value_type;
848
850
852 const value_type *begin,
853 const value_type *end)
854 : Base (cur, begin, end) { }
855
856 const value_type& operator* () const {
857 return Base::operator* ();
858 }
859
860 _RWSTD_OPERATOR_ARROW (const value_type* operator-> () const);
861};
862
863
865// satisfies the requirements in 24.1.5 [lib.random.access.iterators]
866template <class T>
868 : ITER_BASE (std::random_access_iterator_tag, T, int, T*, T&)
869{
870 typedef T value_type;
873 typedef _RWSTD_PTRDIFF_T difference_type;
874 typedef std::random_access_iterator_tag iterator_category;
875
876 RandomAccessIter (): cur_ (0), begin_ (0), end_ (0) { }
877
879 const value_type *begin,
880 const value_type *end)
881 : cur_ (cur), begin_ (begin), end_ (end) { }
882
884 : cur_ (rhs.cur_), begin_ (rhs.begin_), end_ (rhs.end_) { }
885
887 begin_ = end_ = cur_ = 0;
888 }
889
891 cur_ = rhs.cur_;
892 begin_ = rhs.begin_;
893 end_ = rhs.end_;
894 return *this;
895 }
896
898 RW_ASSERT (cur_ != 0 && cur_ != end_);
899 return *cur_;
900 }
901
902 _RWSTD_OPERATOR_ARROW (pointer operator-> () const);
903
904 RandomAccessIter& operator++ () {
905 RW_ASSERT (cur_ != 0 && cur_ != end_);
906 return ++cur_, *this;
907 }
908
909 RandomAccessIter operator++ (int) {
910 RandomAccessIter tmp (*this);
911 return ++*this, tmp;
912 }
913
914 RandomAccessIter& operator-- () {
915 RW_ASSERT (cur_ != 0 && cur_ != begin_);
916 return --cur_, *this;
917 }
918
919 RandomAccessIter operator-- (int) {
920 RandomAccessIter tmp (*this);
921 return --*this, tmp;
922 }
923
925 RW_ASSERT ( cur_ != 0
926 && (!end_ || cur_ + n <= end_)
927 && (!begin_ || cur_ + n >= begin_));
928 return cur_ += n, *this;
929 }
931 return *this += -n;
932 }
933
935 return RandomAccessIter (*this) += n;
936 }
937
939 return RandomAccessIter (*this) -= n;
940 }
941
943 RW_ASSERT (cur_ != 0 && rhs.cur_ != 0);
944 return cur_ - rhs.cur_;
945 }
946
947 bool operator== (const RandomAccessIter &rhs) const {
948 RW_ASSERT (cur_ != 0 && rhs.cur_ != 0);
949 return cur_ == rhs.cur_;
950 }
951
952 bool operator!= (const RandomAccessIter &rhs) const {
953 return !(*this == rhs);
954 }
955
956 bool operator< (const RandomAccessIter &rhs) const {
957 RW_ASSERT (cur_ != 0 && rhs.cur_ != 0);
958 return cur_ < rhs.cur_;
959 };
960
961 bool operator> (const RandomAccessIter &rhs) const {
962 return rhs < *this;
963 }
964
965 bool operator<= (const RandomAccessIter &rhs) const {
966 return !(rhs < *this);
967 }
968
969 bool operator>= (const RandomAccessIter &rhs) const {
970 return !(*this < rhs);
971 }
972
973 reference operator[] (difference_type inx) const {
974 RW_ASSERT ( cur_ != 0
975 && (!end_ || cur_ + inx < end_)
976 && !(begin_ || cur_ + inx >= begin_));
977 return cur_ [inx];
978 }
979
980// private:
981 pointer cur_; // pointer to current element
982 const value_type *begin_; // first in range
983 const value_type *end_; // past-the-end
984};
985
986
988template <class T>
990{
991 typedef T value_type;
994
996
998 const value_type *begin,
999 const value_type *end)
1000 : Base (cur, begin, end) { }
1001
1002 const value_type& operator* () const {
1003 return Base::operator* ();
1004 }
1005
1006 _RWSTD_OPERATOR_ARROW (const value_type* operator-> () const);
1007
1009 return Base::operator[] (inx);
1010 }
1011};
1012
1013
1015template <class T>
1016inline T*
1017make_iter (T *cur, const T*, const T*, T*)
1018{
1019 return cur;
1020}
1021
1022template <class T>
1023inline T*
1024copy_iter (T *ptr, const T*)
1025{
1026 return ptr;
1027}
1028
1029// dummy function argument provided to help broken compilers (PR #29835)
1030
1031template <class T>
1032inline InputIter<T>
1033make_iter (const T *cur, const T *begin, const T *end, const InputIter<T>&)
1034{
1035 return InputIter<T>(cur, begin, end);
1036}
1037
1038template <class T>
1039inline InputIter<T>
1040copy_iter (const InputIter<T> &it, const T*)
1041{
1042 return InputIter<T>(it.cur_, it.ptr_->beg_, it.ptr_->end_);
1043}
1044
1045template <class T>
1046inline const char* type_name (InputIter<T>, const T*)
1047{ return "InputIterator"; }
1048
1049
1050template <class T>
1051inline OutputIter<T>
1052make_iter (T *cur, const T *begin, const T *end, const OutputIter<T>&)
1053{
1054 return OutputIter<T>(cur, begin, end);
1055}
1056
1057template <class T>
1058inline OutputIter<T>
1059copy_iter (const OutputIter<T> &it, const T*)
1060{
1061 return OutputIter<T>(it.cur_, 0, it.ptr_->end);
1062}
1063
1064template <class T>
1065inline const char* type_name (OutputIter<T>, const T*)
1066{ return "OutputIterator"; }
1067
1068
1069template <class T>
1070inline FwdIter<T>
1071make_iter (T *cur, const T *begin, const T *end, const FwdIter<T>&)
1072{
1073 return FwdIter<T>(cur, begin, end);
1074}
1075
1076template <class T>
1077inline FwdIter<T>
1078copy_iter (const FwdIter<T> &it, const T*)
1079{
1080 return FwdIter<T>(it.cur_, 0, it.end_);
1081}
1082
1083template <class T>
1084inline const char* type_name (FwdIter<T>, const T*)
1085{ return "ForwardIterator"; }
1086
1087
1088template <class T>
1089inline ConstFwdIter<T>
1090make_iter (const T *cur, const T *begin, const T *end, const ConstFwdIter<T>&)
1091{
1092 return ConstFwdIter<T>(cur, begin, end);
1093}
1094
1095template <class T>
1096inline ConstFwdIter<T>
1097copy_iter (const ConstFwdIter<T> &it, const T*)
1098{
1099 return ConstFwdIter<T>(it.cur_, 0, it.end_);
1100}
1101
1102template <class T>
1103inline const char* type_name (ConstFwdIter<T>, const T*)
1104{ return "ConstForwardIterator"; }
1105
1106
1107template <class T>
1108inline BidirIter<T>
1109make_iter (T *cur, const T *begin, const T *end, const BidirIter<T>&)
1110{
1111 return BidirIter<T>(cur, begin, end);
1112}
1113
1114template <class T>
1115inline BidirIter<T>
1116copy_iter (const BidirIter<T> &it, const T*)
1117{
1118 return BidirIter<T>(it.cur_, it.begin_, it.end_);
1119}
1120
1121template <class T>
1122inline const char* type_name (BidirIter<T>, const T*)
1123{ return "BidirectionalIterator"; }
1124
1125
1126template <class T>
1127inline ConstBidirIter<T>
1128make_iter (const T *cur, const T *begin, const T *end, const ConstBidirIter<T>&)
1129{
1130 return ConstBidirIter<T>(cur, begin, end);
1131}
1132
1133template <class T>
1134inline ConstBidirIter<T>
1135copy_iter (const ConstBidirIter<T> &it, const T*)
1136{
1137 return ConstBidirIter<T>(it.cur_, it.begin_, it.end_);
1138}
1139
1140template <class T>
1141inline const char* type_name (ConstBidirIter<T>, const T*)
1142{ return "ConstBidirectionalIterator"; }
1143
1144
1145template <class T>
1147make_iter (T *cur, const T *begin, const T *end, const RandomAccessIter<T>&)
1148{
1149 return RandomAccessIter<T>(cur, begin, end);
1150}
1151
1152template <class T>
1155{
1156 return RandomAccessIter<T>(it.cur_, it.begin_, it.end_);
1157}
1158
1159template <class T>
1160inline const char* type_name (RandomAccessIter<T>, const T*)
1161{ return "RandomAccessIterator"; }
1162
1163
1164template <class T>
1166make_iter (const T *cur, const T *begin, const T *end,
1168{
1169 return ConstRandomAccessIter<T>(cur, begin, end);
1170}
1171
1172template <class T>
1175{
1176 return ConstRandomAccessIter<T>(it.cur_, it.begin_, it.end_);
1177}
1178
1179template <class T>
1180inline const char* type_name (ConstRandomAccessIter<T>, const T*)
1181{ return "ConstRandomAccessIterator"; }
1182
1183
1184// temporary to not break the tests which uses struct X
1185#include <rw_value.h>
1186
1187#endif // RW_ALG_TEST_H_INCLUDED
#define T
Definition 17.names.cpp:163
#define rhs
Definition 17.names.cpp:536
#define ptr
Definition 17.names.cpp:525
#define last
Definition 17.names.cpp:487
#define a
Definition 17.names.cpp:109
#define b
Definition 17.names.cpp:110
#define tmp
Definition 17.names.cpp:553
#define s
#define RandomAccessIter
Definition 17.names.cpp:527
#define n
Definition 17.names.cpp:130
#define inx
Definition 17.names.cpp:484
#define val
Definition 17.names.cpp:570
#define InputIter
Definition 17.names.cpp:480
#define U
Definition 17.names.cpp:164
const minus< T > & operator-(const minus< T > &lhs, const minus< T > &rhs)
const plus_asgn< T > & operator*(const plus_asgn< T > &lhs, const plus_asgn< T > &rhs)
const char * type_name()
const int end
const int cur
void operator+(typename A< T >::I, const A< T > &)
#define _RWSTD_REINTERPRET_CAST(T, x)
Definition _defs.h:535
#define _RWSTD_UNUSED(arg)
Definition _defs.h:972
#define _RWSTD_CONST_CAST(T, x)
Definition _defs.h:536
bool operator>(const DistancePair &lhs, const DistancePair &rhs)
Definition graph.cpp:47
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14737
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14762
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14787
bool operator<(const lt_comp< T > &, const lt_comp< T > &)
bool operator==(const eq_comp< T > &, const eq_comp< T > &)
_TEST_EXPORT int gen_seq()
Definition alg_test.cpp:38
@ def_ctor
@ cpy_ctor
@ no_ctor
T * make_iter(T *cur, const T *, const T *, T *)
void operator&&(const conv_to_bool &, bool)
void operator||(const conv_to_bool &, bool)
_TEST_EXPORT unsigned ilog10(_RWSTD_SIZE_T)
#define ITER_BASE(ign1, ign2, ign3, ign4, ign5)
_TEST_EXPORT unsigned ilog2(_RWSTD_SIZE_T)
bool is_sorted_gt(InputIterator first, InputIterator last)
Definition rw_alg_test.h:92
bool is_sorted_lt(InputIterator first, InputIterator last)
Definition rw_alg_test.h:75
T * copy_iter(T *ptr, const T *)
_TEST_EXPORT int gen_rnd()
Definition alg_test.cpp:66
_TEST_EXPORT int gen_seq_2lists()
Definition alg_test.cpp:47
_TEST_EXPORT int gen_subseq()
Definition alg_test.cpp:56
bool is_sorted(InputIterator first, InputIterator last, Predicate pred)
Definition rw_alg_test.h:59
#define _TEST_EXPORT
Definition rw_testdefs.h:55
#define RW_ASSERT(expr)
BidirIter(pointer cur, const value_type *begin, const value_type *end)
bool operator==(const BidirIter &rhs) const
reference operator*() const
pointer cur_
const value_type * begin_
const value_type * end_
bool operator!=(const BidirIter &rhs) const
_RWSTD_PTRDIFF_T difference_type
std::bidirectional_iterator_tag iterator_category
BidirIter(const BidirIter &rhs)
value_type * pointer
BidirIter & operator++()
_RWSTD_OPERATOR_ARROW(pointer operator->() const)
BidirIter & operator--()
BidirIter & operator=(const BidirIter &rhs)
value_type & reference
const value_type & operator*() const
BidirIter< const value_type > Base
ConstBidirIter(const value_type *cur, const value_type *begin, const value_type *end)
_RWSTD_OPERATOR_ARROW(const value_type *operator->() const)
FwdIter< const value_type > Base
ConstFwdIter(const value_type *cur, const value_type *begin, const value_type *end)
_RWSTD_OPERATOR_ARROW(const value_type *operator->() const)
const value_type & operator*() const
const value_type & operator*() const
const value_type & operator[](difference_type inx) const
ConstRandomAccessIter(const value_type *cur, const value_type *begin, const value_type *end)
RandomAccessIter< const value_type > Base
Base::difference_type difference_type
_RWSTD_OPERATOR_ARROW(const value_type *operator->() const)
FwdIter(pointer cur, const value_type *, const value_type *end)
_RWSTD_OPERATOR_ARROW(pointer operator->() const)
_RWSTD_PTRDIFF_T difference_type
FwdIter & operator++()
bool operator!=(const FwdIter &rhs) const
std::forward_iterator_tag iterator_category
value_type * pointer
pointer cur_
value_type & reference
FwdIter(const FwdIter &rhs)
FwdIter & operator=(const FwdIter &rhs)
reference operator*() const
const value_type * end_
bool operator==(const FwdIter &rhs) const
const value_type * beg_
const value_type * end_
Shared(const value_type *cur, const value_type *beg, const value_type *end)
const value_type * cur_
_RWSTD_PTRDIFF_T difference_type
value_type & reference
Shared * ptr_
std::input_iterator_tag iterator_category
_RWSTD_OPERATOR_ARROW(const value_type *operator->() const)
const value_type * cur_
value_type * pointer
Shared(pointer cur, const value_type *end)
const value_type * end_
const value_type * begin_
value_type * pointer
value_type & reference
_RWSTD_PTRDIFF_T difference_type
OutputIter(pointer cur, const value_type *, const value_type *end)
Shared * ptr_
_RWSTD_OPERATOR_ARROW(pointer operator->() const)
pointer cur_
OutputIter(const OutputIter &rhs)
std::output_iterator_tag iterator_category
RandomAccessIter(const RandomAccessIter &rhs)
const value_type * end_
_RWSTD_OPERATOR_ARROW(pointer operator->() const)
reference operator*() const
reference operator[](difference_type inx) const
value_type & reference
const value_type * begin_
std::random_access_iterator_tag iterator_category
_RWSTD_PTRDIFF_T difference_type
RandomAccessIter(pointer cur, const value_type *begin, const value_type *end)
value_type * pointer
Size(IntegralT val, int)
IntegralT IntegralType
assign & operator=(const assign &rhs)
base(const base< cpy_ctor > &rhs)
base(const base<(def_ctor|cpy_ctor)> &rhs)
reference operator()(const argument_type &, const argument_type &) const
argument_type & reference
conv_to_bool operator()(const T &a, const T &b) const
static conv_to_bool make(bool val)
bool conv_to_bool::* UniquePtr
argument_type & reference
reference operator()(const argument_type &) const
T argument_type
conv_to_bool operator()(const T &a) const