Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Liquid Web Managed Dedicated Server: RAID 1 SSD with 16GB of RAM minimum! 24/7 On-Site Heroic Support! Industry-Leading SLA!

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Liquid Web Cloud VPS Hosting

8,518 questions

11,802 answers

573 users

How to insert elements to a set with insert_iterator in C++

1 Answer

0 votes
#include <iostream>
#include <set>
#include <iterator>

using std::set;
using std::cout;
using std::endl;

void print(const set<int>& st)
{
	for (auto element : st) {
		cout << element << ' ';
	}
	cout << endl;
}

int main()
{
	set<int> st;

	std::insert_iterator<set<int> > itr(st, st.begin());

	*itr = 1;
	itr++;
	*itr = 2;
	itr++;
	*itr = 3;
	itr++;
	*itr = 4;

	print(st);
}


/*
run:

1 2 3 4

*/

 




answered Jan 23 by avibootz
edited Jan 24 by avibootz
...