//文件名:CHAPTER9-1.cpp
#include
#include
#if _MSC_VER > 1020 // if VC++ version is > 4.2
using namespace std; // std c++ libs implemented in std
#endif
int main( )
{
set ::iterator s1_Iter, s2_Iter, s3_Iter, s4_Iter, s5_Iter, s6_Iter;
// Create an empty set s0 of key type integer
set s0;
// Create an empty set s1 with the key comparison
// function of less than, then insert 4 elements
set s1;
s1.insert( 10 );
s1.insert( 20 );
s1.insert( 30 );
s1.insert( 40 );
// Create an empty set s2 with the key comparison
// function of geater than, then insert 2 elements
set s2;
s2.insert(10);
s2.insert(20);
// Create a set s3 with the
// allocator of set s1
set ::allocator_type s1_Alloc;
s1_Alloc = s1.get_allocator( );
set s3( less( ), s1_Alloc );
s3.insert( 30 );
// Create a copy, set s4, of set s1
set s4( s1 );
// Create a set s5 by copying the range s1[_First, _Last)
set ::const_iterator s1_bcIter, s1_ecIter;
s1_bcIter = s1.begin( );
s1_ecIter = s1.begin( );
s1_ecIter++;
s1_ecIter++;
// set s5( s1_bcIter, s1_ecIter );
// Create a set s6 by copying the range s4[_First, _Last)
// and with the allocator of set s2
set ::allocator_type s2_Alloc;
s2_Alloc = s2.get_allocator( );
// set s6( s4.begin( ), ++s4.begin( ), less( ), s2_Alloc );
cout for ( s1_Iter = s1.begin( ); s1_Iter != s1.end( ); s1_Iter++ )
cout cout cout cout for ( s3_Iter = s3.begin( ); s3_Iter != s3.end( ); s3_Iter++ )
cout cout cout for ( s4_Iter = s4.begin( ); s4_Iter != s4.end( ); s4_Iter++ )
cout cout /* cout for ( s5_Iter = s5.begin( ); s5_Iter != s5.end( ); s5_Iter++ )
cout cout cout for ( s6_Iter = s6.begin( ); s6_Iter != s6.end( ); s6_Iter++ )
cout cout return 0;
}