STL set class
- From: KBI <KBI@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 29 Oct 2006 05:48:01 -0800
Hello,
I am using VC++6.0. ( I know it is old but...)
I tried the following code and got C2664 compile error on line " set <int>
s5( s1_bcIter, s1_ecIter ); ".
The code is from http://msdn2.microsoft.com/en-us/library/2yy2xd0h.aspx .
Could someone tell me why?
Thanks in advance.
Byung-In Kim
---------------------------------------------
// set_set.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int>::iterator s1_Iter, s2_Iter, s3_Iter, s4_Iter, s5_Iter, s6_Iter;
// Create an empty set s0 of key type integer
set <int> s0;
// Create an empty set s1 with the key comparison
// function of less than, then insert 4 elements
set <int, less<int> > 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 <int, greater<int> > s2;
s2.insert(10);
s2.insert(20);
// Create a set s3 with the
// allocator of set s1
set <int>::allocator_type s1_Alloc;
s1_Alloc = s1.get_allocator( );
set <int> s3( less<int>( ), s1_Alloc );
s3.insert( 30 );
// Create a copy, set s4, of set s1
set <int> s4( s1 );
// Create a set s5 by copying the range s1[_First, _Last)
set <int>::const_iterator s1_bcIter, s1_ecIter;
s1_bcIter = s1.begin( );
s1_ecIter = s1.begin( );
s1_ecIter++;
s1_ecIter++;
set <int> s5( s1_bcIter, s1_ecIter );
// Create a set s6 by copying the range s4[_First, _Last)
// and with the allocator of set s2
set <int>::allocator_type s2_Alloc;
s2_Alloc = s2.get_allocator( );
set <int> s6( s4.begin( ), ++s4.begin( ), less<int>( ), s2_Alloc );
cout << "s1 =";
for ( s1_Iter = s1.begin( ); s1_Iter != s1.end( ); s1_Iter++ )
cout << " " << *s1_Iter;
cout << endl;
cout << "s2 = " << *s2.begin( ) << " " << *++s2.begin( ) << endl;
cout << "s3 =";
for ( s3_Iter = s3.begin( ); s3_Iter != s3.end( ); s3_Iter++ )
cout << " " << *s3_Iter;
cout << endl;
cout << "s4 =";
for ( s4_Iter = s4.begin( ); s4_Iter != s4.end( ); s4_Iter++ )
cout << " " << *s4_Iter;
cout << endl;
cout << "s5 =";
for ( s5_Iter = s5.begin( ); s5_Iter != s5.end( ); s5_Iter++ )
cout << " " << *s5_Iter;
cout << endl;
cout << "s6 =";
for ( s6_Iter = s6.begin( ); s6_Iter != s6.end( ); s6_Iter++ )
cout << " " << *s6_Iter;
cout << endl;
}
.
- Follow-Ups:
- Re: STL set class
- From: Igor Tandetnik
- Re: STL set class
- Prev by Date: Re: Is ostringstream slow?
- Next by Date: Re: STL set class
- Previous by thread: Traversing multiple vectors "in parallel"
- Next by thread: Re: STL set class
- Index(es):
Relevant Pages
|
Loading