Displaying 3 results from an estimated 3 matches for "ptr_range".
Did you mean:
gtt_range
2009 May 15
0
[LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)
On Friday 15 May 2009 05:50, Jay Foad wrote:
> > 3. Any comments on the patch itself?
> >
> > The one major thing to be aware of is that it isn't safe to use &V[0]
> > when V is an empty std::vector
>
> Oh dear. That's a bit of a flaw in the plan. I suppose the solution is
> to switch to SmallVector whenever this might be a problem.
Or use iterators.
2009 May 15
2
[LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)
....end()) { }
Iter begin() { return Begin; }
Iter end() { return End; }
// ... other Sequence methods ...
};
And encapsulate the logic to deal with the empty sequence problem in a
function:
template<typename ConvertibleToRange>
range<typename ConvertibleToRange::value_type*>
ptr_range(ConvertibleToRange &seq) {
typename ConvertibleToRange::iterator i = seq.begin(), e = seq.end();
if (i == e)
return range<typename ConvertibleToRange::value_type*>();
return range<typename ConvertibleToRange::value_type*>(&*i, &*i +
(e - i));
};
So that:
St...
2009 May 15
3
[LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)
> 3. Any comments on the patch itself?
>
> The one major thing to be aware of is that it isn't safe to use &V[0] when V
> is an empty std::vector
Oh dear. That's a bit of a flaw in the plan. I suppose the solution is
to switch to SmallVector whenever this might be a problem.
I'm a bit concerned that any new &empty[0] problems that are
introduced will go unnoticed.