J
Joost Kraaijeveld
Hi,
The code below does not compile if I use the std::set, but it compiles
OK if I use the std::vector. Can anyone tell me why this is?
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
struct Integer
{
Integer(int anInt) : integer(anInt)
{}
bool operator<( const Integer& anInteger) const
{ return integer < anInteger.integer;}
void print()
{std::cout << integer << std::endl;}
int integer;
};
int main(int argc, char* argv[])
{
// std::vector<Integer> collection(5,2);
std::set<Integer> collection(5,2);
std::for_each(collection.begin(),
collection.end(),
std::mem_fun_ref(&Integer:rint));
return 0;
}
TIA
Joost
The code below does not compile if I use the std::set, but it compiles
OK if I use the std::vector. Can anyone tell me why this is?
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
struct Integer
{
Integer(int anInt) : integer(anInt)
{}
bool operator<( const Integer& anInteger) const
{ return integer < anInteger.integer;}
void print()
{std::cout << integer << std::endl;}
int integer;
};
int main(int argc, char* argv[])
{
// std::vector<Integer> collection(5,2);
std::set<Integer> collection(5,2);
std::for_each(collection.begin(),
collection.end(),
std::mem_fun_ref(&Integer:rint));
return 0;
}
TIA
Joost