Click here to Skip to main content
15,900,461 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: [SOS]Winsock in ATL Dll [SOS] Pin
Eytukan12-Oct-06 18:24
Eytukan12-Oct-06 18:24 
QuestionATL,WTL time object in debug and release config Pin
Samy_Ibraheem_Mo26-Sep-06 7:20
Samy_Ibraheem_Mo26-Sep-06 7:20 
GeneralFunction object destructor called multiple times in std::for_each loop Pin
Rob Caldecott26-Sep-06 7:02
Rob Caldecott26-Sep-06 7:02 
GeneralA solution, of sorts Pin
Rob Caldecott26-Sep-06 7:21
Rob Caldecott26-Sep-06 7:21 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Zac Howland26-Sep-06 8:25
Zac Howland26-Sep-06 8:25 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Rob Caldecott26-Sep-06 8:30
Rob Caldecott26-Sep-06 8:30 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Zac Howland26-Sep-06 8:43
Zac Howland26-Sep-06 8:43 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Rob Caldecott26-Sep-06 10:17
Rob Caldecott26-Sep-06 10:17 
It compiles. And only one function object is used.

Basically, the constructor of my function object creates a new class (via a boost::smart_ptr), the operator() adds data to the class, and the destructor adds the class to a container (that is passed by reference to the function object constructor). The additional constructors/destructors in my first attempt were obviously causing problems, but passing the function object by reference seems to work. The code would look something like this:

class foo { ... };
...
struct function_object
{
	boost::shared_ptr<foo> sp_;
	std::vector<boost::shared_ptr<foo> >& vec_;
	
	function_object(std::vector<boost::shared_ptr<foo> >& vec) : vec_(vec), sp_(new foo)
	{
	}
	
	~function_object()
	{
		vec_.push_back(sp_);
	}
	
	void operator()(int n) const
	{
		// Do something with sp_ here
	}
};
...
// Example
std::vector<boost::shared_ptr<foo> > vec;
std::vector<int> int_vec;
int_vec.push_back(1);
int_vec.push_back(2);
function_object f(vec);
std::for_each<std::vector<int>::const_iterator, function_object&>(int_vec.begin(), int_vec.end(), f);



Kicking squealing Gucci little piggy.

GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Zac Howland26-Sep-06 10:59
Zac Howland26-Sep-06 10:59 
Questionwhat is WTL ? Pin
Sakthiu26-Sep-06 3:36
Sakthiu26-Sep-06 3:36 
AnswerRe: what is WTL ? Pin
led mike26-Sep-06 7:30
led mike26-Sep-06 7:30 
AnswerRe: what is WTL ? Pin
Michael Dunn2-Oct-06 7:35
sitebuilderMichael Dunn2-Oct-06 7:35 
GeneralRe: what is WTL ? Pin
Steve S27-Sep-06 1:22
Steve S27-Sep-06 1:22 
QuestionBHO cpu usage is too high Pin
daheitou26-Sep-06 3:10
daheitou26-Sep-06 3:10 
QuestionWTL code wrappers for Scintilla Pin
Igor Vigdorchik25-Sep-06 8:29
Igor Vigdorchik25-Sep-06 8:29 
AnswerRe: WTL code wrappers for Scintilla Pin
Alain Rist25-Sep-06 12:43
Alain Rist25-Sep-06 12:43 
GeneralRe: WTL code wrappers for Scintilla Pin
Igor Vigdorchik25-Sep-06 14:57
Igor Vigdorchik25-Sep-06 14:57 
Questionregister an attributed ATL7 com dll file [modified] Pin
Samy_Ibraheem_Mo24-Sep-06 10:04
Samy_Ibraheem_Mo24-Sep-06 10:04 
AnswerRe: register an attributed ATL7 com dll file Pin
Samy_Ibraheem_Mo24-Sep-06 17:13
Samy_Ibraheem_Mo24-Sep-06 17:13 
AnswerRe: register an attributed ATL7 com dll file Pin
User 21559724-Sep-06 22:31
User 21559724-Sep-06 22:31 
AnswerRe: register an attributed ATL7 com dll file Pin
Zodiacon25-Sep-06 6:59
Zodiacon25-Sep-06 6:59 
QuestionComposite Control Info Pin
Demian Panello21-Sep-06 17:06
Demian Panello21-Sep-06 17:06 
AnswerRe: Composite Control Info Pin
Jörgen Sigvardsson22-Sep-06 6:54
Jörgen Sigvardsson22-Sep-06 6:54 
QuestionUsing STL with WTL is causing problems Pin
TClarke20-Sep-06 22:52
TClarke20-Sep-06 22:52 
AnswerRe: Using STL with WTL is causing problems Pin
Rob Caldecott20-Sep-06 23:09
Rob Caldecott20-Sep-06 23:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.