Newsgroup: comp.lang.c++
Subject: Iterator pair as a function argument?
From: nvangogh <nvangogh@...>
Date: Wed, 19 Feb 2014 20:22:47 +0000
Suppose I have a vector<int> values. Now the pair values.begin() and
values.end() will cover the range of the vector.
I am writing a simple function that takes the pair of iterators as
arguments along with an int value. The function then returns a bool to
indicate if the int value is found in the vector.
The first problem I have is to question if it is possible to pass
iterators as distinct arguments to a function? I would have thought that
the only way to accomplish this would be to pass the vector as a
reference, from there the function can use the iterators to do it's work.
I was thinking the correct definition would be
bool find_value (vector<int>&, int);
Or is there a way to pass an iterator pair as function arguments which I
have missed?
Subject: Iterator pair as a function argument?
From: nvangogh <nvangogh@...>
Date: Wed, 19 Feb 2014 20:22:47 +0000
Suppose I have a vector<int> values. Now the pair values.begin() and
values.end() will cover the range of the vector.
I am writing a simple function that takes the pair of iterators as
arguments along with an int value. The function then returns a bool to
indicate if the int value is found in the vector.
The first problem I have is to question if it is possible to pass
iterators as distinct arguments to a function? I would have thought that
the only way to accomplish this would be to pass the vector as a
reference, from there the function can use the iterators to do it's work.
I was thinking the correct definition would be
bool find_value (vector<int>&, int);
Or is there a way to pass an iterator pair as function arguments which I
have missed?
via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1jJceFN
View all the progranning help forums at:
http://ift.tt/1dP9txN
No comments:
Post a Comment