1// constructing sets
2#include <iostream>
3#include <set>
4
5bool fncomp (int lhs, int rhs) {return lhs<rhs;}
6
7struct classcomp {
8 bool operator() (const int& lhs, const int& rhs) const
9 {return lhs<rhs;}
10};
11
12int main ()
13{
14 std::set<int> first; // empty set of ints
15
16 int myints[]= {10,20,30,40,50};
17 std::set<int> second (myints,myints+5); // range
18
19 std::set<int> third (second); // a copy of second
20
21 std::set<int> fourth (second.begin(), second.end()); // iterator ctor.
22
23 std::set<int,classcomp> fifth; // class as Compare
24
25 bool(*fn_pt)(int,int) = fncomp;
26 std::set<int,bool(*)(int,int)> sixth (fn_pt); // function pointer as Compare
27
28 return 0;
29}