Boost Users :
Subject: Re: [Boost-users] Boost.Range fancify please
From: anony (janezz55_at_[hidden])
Date: 2009-12-27 18:52:55
Eric Niebler pravi:
>> Are you certain I am wrong? The array is multidimensional and contiguous
>> in memory. The boost::begin() and boost::end() just return pointers. I
>> have checked if all the floats scale correctly and they do.
> I'm pretty certain. You're straying into undefined behavior by making a
> range using iterators from different arrays.
The make_iterator_range() function sees only 2 pointers and these are
all it cares about. Now, let's check the standard:
ISO-IEC-14882 Section 8.3.4 Array, page 137:
An object of array type contains a contiguously allocated non-
empty set of N sub-objects of type T.
The pointers I provide point to the beginning and the end of the
vertices multidimensional array. The array must be contiguously
allocated, as specified in the standard, hence I don't see which aspect
of what I am doing in undefined, if the functions boost::begin() and
boost::end() work as expected (again, they return pointers, not fancy
Did I mention the debugger shows everything is just perfect.
>>> Why not just use BOOST_FOREACH correctly?
>>> BOOST_FOREACH(float (&rgf), vertices)
>>> BOOST_FOREACH(float& f, rgf)
>>> f *= scale;
>> Double loop, oops. Not fancy enough.
> Are you joking?
I was looking for fancy (i.e. elegant) code, yours is too complicated.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net