Boost logo

Boost :

From: nbecker_at_[hidden]
Date: 2002-02-01 07:58:17

>>>>> "rogeeff" == rogeeff <rogeeff_at_[hidden]> writes:

    rogeeff> --- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
>> In principle I would be, but I don't have time to check it over in
    rogeeff> detail
>> right now. If you and Tom Becker would like to resolve your
    rogeeff> differences (I
>> too am concerned about the non-portable rounding direction of
    rogeeff> negative
>> numbers) and come up with a documentation page, I'd be happy to
    rogeeff> accept it.
>> -Dave

I haven't checked the code carefully, but my concern is that the '%'
operator when used with negative args returns either positive or
negative values, machine dependent. Usually this requires an explicit
test or the code won't be correct in both cases. There was no such
test in this code, so I was suspicious.

    rogeeff> To Neal Backer:
    rogeeff> I do not see what do we buy making Policy methods static. Dave could
    rogeeff> you clarify following question: since current design of
    rogeeff> iterator_adaptor allows implemnetation if adaptor policies both as
    rogeeff> member funtion and static function (since policy could be accessed
    rogeeff> through this or Base.policy()), is there any valid reasons to prefere
    rogeeff> one way over another?

I believe the code is more clear. Since the adaptor object is passed
as an argument to the unary functions, I find it confusing if the
argument is not used. In the case of binary functions, the lack of
symmetry is also confusing. I was under the impression, perhaps
wrongly, that the policies were really intended to be static, but were
not made static only to satisfy some broken compiler.

    rogeeff> Abould distance(): I do not see why do would you need distance to be
    rogeeff> always positive. Could you clarify Neal?

std::copy will not work without fixing distance, at least with gcc-3.0.1
and it's version of the libstdc++. Please try these tests:
The problem is that the definition of std::copy(x1, x2) will stop if
x2 <= x1. Thus, if logically x1 is before x2 distance from x1 to x2
must be positive. Also, other algorithms might want this.

int main () {
  std::vector<int> v (10);
  for (int i = 0; i < 10; i++)
    v[i] = i;
  typedef boost::cycle_iterator_generator<std::vector<int>::iterator>::type type;

  type i = boost::make_cycle_iterator (v.begin(), v.end());
  type j = i + 2;

  // std::copy (boost::make_cycle_iterator (v.begin(), v.end()), boost::make_cycle_iterator (v.begin(), v.end()) + 2, std::ostream_iterator<int> (std::cout, "\n"));
  // std::copy (boost::make_cycle_iterator (v.begin(), v.end()) + 2, boost::make_cycle_iterator (v.begin(), v.end()), std::ostream_iterator<int> (std::cout, "\n"));
  // std::copy (boost::make_cycle_iterator (v.begin(), v.end()) + 2, boost::make_cycle_iterator (v.begin(), v.end()+1), std::ostream_iterator<int> (std::cout, "\n"));

  boost::cyclic_container<std::vector<int> > c (v);

  std::copy (c.begin(), c.end(), std::ostream_iterator<int> (std::cout, " "));
  std::cout << '\n';
  c.advance (-1);
  std::copy (c.begin(), c.end(), std::ostream_iterator<int> (std::cout, " "));
  std::cout << '\n';
  c.advance (-1);
  std::copy (c.begin(), c.end(), std::ostream_iterator<int> (std::cout, " "));
  std::cout << '\n';


Boost list run by bdawes at, gregod at, cpdaniel at, john at