This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Testsuite Iterators


The recent patch to search_n I submitted has a specialisation for random access iterators, and therefore the test suite should test both the non-random access and the random access versions for correctness.

After the advise of Martin Sebor, I decided to write a set of iterator adaptors which would, given an array of some type T, provide iterators of various types over this array.

I now have various different methods of doing this, and I thought I would ask which people considered the most sensible to try to submit for inclusion for use in the testsuite.

a) Just use vector<> when you want a random access iterator, list<> when you want a bidirection one, etc.

b) Make a set of iterators, each of which has a single constructor taking a single pointer.

c) Make a set of iterators, each of which has a constructor which takes 3 elements (2 in the case of forward/input/output iterators), denoting the current iterator position and the first and last positions the iterator can take

d) Make "minimal containers" which take 2 pointers, one for the start and one for the end of the range. Give these begin(),end() and possibly a new function getIt(int i) which returns an iterator pointing to ith element.

e) Make full blown proper containers, which once again take 2 pointers representing the beginning and the end of the range which the iterators should range over.

Personally, I am tempted by c) or d). d) looks slightly nicer but doesn't really save that much typing. I would be interested to know of any other opinions.

I would hope after polishing and submitting these iterator wrappers, that they would then be used in the testsuite as firstly they would be as "tight" as possible with regards the standard, stopping at any undefined behaviour, and secondly they would remove dependance on vector,list, etc. which may have bugs or pecularities of their own.

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]