Home | History | Annotate | Download | only in eh
      1            #include <iostream>
      2            #include <set>
      3            #include <vector>
      4 
      5            template<class T>
      6            inline void printElements(const T& coll, const char* msg = "")
      7            {
      8            typename T::const_iterator it;
      9            std::cout << msg;
     10            for(it = coll.begin(); it != coll.end(); ++it) {
     11            std::cout << *it << ' ';
     12            }
     13            std::cout << std:: endl;
     14            }
     15 
     16            int main(int /* argc */, char** /* argv */)
     17            {
     18            std::set<int> set1, set2;
     19            std::vector<int> aVector;
     20 
     21            aVector.push_back(1);
     22            aVector.push_back(1);
     23 
     24            set1.insert(aVector.begin(), aVector.end());
     25 
     26            set2.insert(1);
     27            set2.insert(1);
     28 
     29            printElements(aVector, "vector: ");
     30            printElements(set1, "set1 : ");
     31            printElements(set2, "set2 : ");
     32 
     33            return 0;
     34            }
     35 # if 0
     36 # include <iostream>
     37 main()
     38 {
     39   // std::stringstream tstr;
     40   std::cout<<"hello world\n";
     41 }
     42 # endif
     43