MistyD
MistyD

Reputation: 17223

boost function instantion with nothing

I am currently using the following piece of code in my dll file:

typedef boost::function<void(int)> Function_Callback_type;

#pragma data_seg(".SHARED")
int common = 0 ;
Function_Callback_type  funct_callback;
#pragma data_seg()
#pragma comment(linker, "/section:.SHARED,RWS")

Now I want to assign a value to funct_callback. I read that if something is kept in the shared data segment of a dll file it needs to be initialized. My question is: How can I initialize the funct_callback to nothing ?

Upvotes: 0

Views: 240

Answers (1)

Columbo
Columbo

Reputation: 60989

My question is how can I initialize the funct_callback to nothing ?

If you mean "no function" or "no content": Don't do anything, the default-constructor is called automatically.

If you want to assign an empty function that does nothing, either use a lamda

Function_Callback_type  funct_callback = [] (int) {};

Or define an empty function yourself and assign that. (Or a functor class with an empty function call operator and assign a temporary of that class type)

Upvotes: 1

Related Questions