How to store range iterator?

T

toton

Hi,
I have a view class for a vector, which stores different range for a
few vectors, and provides a way to iterate over the range.
The range class takes a pair of iterator, as given in post
http://groups.google.com/group/comp...1231f?lnk=gst&q=range&rnum=2#a282fc1288b1231f

However, as the range class do not have a default ctor, and range is
not known when view class is constructed I can not initialize range
class at initialization list.Thus I need to store range class pointer
inside view class. When I want to set a new range for the view class, I
use,

void CC::setPtuRange(const PointRange& range){
if(!_reconstructedPoints)
_reconstructedPoints = new PointRange(range);
}
where _reconstructedPoints is a range class for CC (member variable).
Also I set it only once (but not at constructor). At constructor it is
initialized as NULL & destructor deleted.
Also when I return the range class, I use
PointRange CC::points()const{
return *_reconstructedPoints;
}
PointRange is typedef as
typedef PointBuffer::const_iterator PointIterator;
typedef range<PointIterator> PointRange
where PointBuffer is a vector<Point>
My questions are,
1) is it valid to return a value for the pointer with dereferencing
operator? Or I need to return a pointer directly?
2) can I also return a a reference? What is the best way to do it?
Thanks for any help .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top