Re: [Boost-bugs] [Boost C++ Libraries] #3659: warning when using boost::counting_iterator<int> and std::vector<int> on MSVC

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3659: warning when using boost::counting_iterator<int> and std::vector<int> on MSVC
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-06 06:37:08


#3659: warning when using boost::counting_iterator<int> and std::vector<int> on
MSVC
---------------------------+------------------------------------------------
  Reporter: anonymous | Owner: dave
      Type: Bugs | Status: closed
 Milestone: Boost 1.42.0 | Component: iterator
   Version: Boost 1.41.0 | Severity: Cosmetic
Resolution: invalid | Keywords:
---------------------------+------------------------------------------------

Comment (by Sergey Mitsyn <svm at jinr.ru>):

 BTW, not every difference is representable even with current strategy. In
 this code, difference overflows without issuing any warning:

 {{{
 typedef boost::counting_iterator<boost::intmax_t> iterator_type;
 iterator_type a(-0x7ffFfffFfffFfffF), b(0x7ffFfffFfffFfffF);

 std::cout << *a << '\t' << *b << std::endl;
 std::cout << (b-a) << std::endl;
 }}}

 , the output is:

 {{{
 -9223372036854775807 9223372036854775807
 -2
 }}}

 Thus {{{boost::counting_iterator}}} cannot provide guarantee that
 {{{(b-a)}}} cannot overflow for any {{{Incrementable}}}. Plus, I believe
 that everybody would expect {{{(b-a)}}} to be equal to {{{(*b-*a)}}}.

 Please, switch to strategy with overflows. :)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3659#comment:9>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC