RE: [Boost-Users] Problems with iterator_adaptors

11 Apr
2003
11 Apr
'03
3:08 p.m.
Olaf Petzold wrote:
The problem is that the result of % and / (and by implication %= and /=) is implementation defined if either operand is negative. Most implementations round the quotient towards zero and produce a remainder with the same sign as the quotient. Evidently you want to have a non-negative remainder always. The simplest solution, I think, is: DifferenceType length = std::distance( m_begin, m_end ); n %= length; if (n < 0) n += length;
8103
Age (days ago)
8103
Last active (days ago)
0 comments
1 participants
participants (1)
-
Ben Hutchings