N
Nephi Immortal
I guess that Microsoft’s vector code is not good because iterator is
less flexible. If you want to use operator<= or operator>, then
assert is triggered.
I suppose to use operator> if I don’t want to use reverse_iterator.
Why do vector documentation tell to use only operator!= or operator<?
I wish Microsoft should rewrite their vector code. All iterators
must always use signed integer instead of unsigned integer.
#include <vector>
using namespace std;
int main()
{
vector< int > a;
a.push_back( 1 );
a.push_back( 2 );
a.push_back( 3 );
a.push_back( 4 );
vector< int >::iterator B = a.begin();
vector< int >::iterator E = a.end();
vector< int >::iterator I;
int _v;
// OK
for( I = B; I != E; ++I )
_v = *I;
// OK
for( I = B; I < E; ++I )
_v = *I;
// ERROR
for( I = B; I <= E; ++I )
_v = *I;
/* operator<= should call operator< automatically */
// ERROR
for( I = E; I != B; --I )
_v = *I;
// ERROR
for( I = E; I > B; --I )
_v = *I;
return 0;
}
less flexible. If you want to use operator<= or operator>, then
assert is triggered.
I suppose to use operator> if I don’t want to use reverse_iterator.
Why do vector documentation tell to use only operator!= or operator<?
I wish Microsoft should rewrite their vector code. All iterators
must always use signed integer instead of unsigned integer.
#include <vector>
using namespace std;
int main()
{
vector< int > a;
a.push_back( 1 );
a.push_back( 2 );
a.push_back( 3 );
a.push_back( 4 );
vector< int >::iterator B = a.begin();
vector< int >::iterator E = a.end();
vector< int >::iterator I;
int _v;
// OK
for( I = B; I != E; ++I )
_v = *I;
// OK
for( I = B; I < E; ++I )
_v = *I;
// ERROR
for( I = B; I <= E; ++I )
_v = *I;
/* operator<= should call operator< automatically */
// ERROR
for( I = E; I != B; --I )
_v = *I;
// ERROR
for( I = E; I > B; --I )
_v = *I;
return 0;
}