Click here to Skip to main content
15,885,366 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Need help with this little C program Pin
Member 1197963713-Sep-15 12:24
Member 1197963713-Sep-15 12:24 
AnswerRe: Need help with this little C program Pin
CPallini13-Sep-15 21:13
mveCPallini13-Sep-15 21:13 
QuestionRe: Need help with this little C program Pin
Member 1197963714-Sep-15 2:42
Member 1197963714-Sep-15 2:42 
AnswerRe: Need help with this little C program Pin
Member 1197963714-Sep-15 2:55
Member 1197963714-Sep-15 2:55 
GeneralRe: Need help with this little C program Pin
CPallini14-Sep-15 3:40
mveCPallini14-Sep-15 3:40 
SuggestionRe: Need help with this little C program Pin
David Crow14-Sep-15 4:40
David Crow14-Sep-15 4:40 
GeneralRe: Need help with this little C program Pin
Member 1197963714-Sep-15 6:10
Member 1197963714-Sep-15 6:10 
QuestionC++ lambda callbacks, how to initialize with NULL pointer ? Pin
Member 853403512-Sep-15 0:45
Member 853403512-Sep-15 0:45 
Hi all,

I need callback functions between different classes. I had already a solution based on stl, which was compilable with VS2010. Unfortunately I was not able to find a way to compile it with VS2015. I got weird error messages.

Now I found a solution with lamda C++11 lambda function pointers. Actually it works, but I have one open issue.

For having a save source code, I want to initialize the function pointer with NULL. But compiler is producing weird error messages again!

My Code:

typedef std::function<bool(int, int, CString*)> _tcedit_cb_;

class MyClass 
{
public:
   MyClass ()
   {
	m_cbGetItemData = NULL;  // <--- compile error because of the NULL pointer 
   }
   _tcedit_cb_ m_cbGetItemData;

   ...
}


How I can initialize the function callback pointer? I need to initialize in order to avoid running into illegal code!

e.g. I tried to cast ... = (_tcedit_cb_) NULL;

error messages:
c:\program files(x86)\microsoft visual studio 14.0\vc\include\type_traits(1501) : error C2893 : Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...)'
	1>  c:\program files(x86)\microsoft visual studio 14.0\vc\include\type_traits(1501) : note : With the following template arguments :
	1>  c:\program files(x86)\microsoft visual studio 14.0\vc\include\type_traits(1501) : note : '_Callable=_Decayed &'
	1>  c:\program files(x86)\microsoft visual studio 14.0\vc\include\type_traits(1501) : note : '_Types={int, int, ATL::CStringT<wchar_t,StrTraitMFC<wchar_t,ATL::ChTraitsCRT<wchar_t>>> }'
	1>  c:\program files(x86)\microsoft visual studio 14.0\vc\include\functional(210) : note : see reference to function template instantiation '_Rx std::_Invoke_ret<_Rx,_Callable&,_Ty,_Ty,ATL::CStringT<wchar_t,StrTraitMFC<wchar_t,ATL::ChTraitsCRT<wchar_t>>>>(std::_Forced<_Rx,false>,_Callable &,_Ty &&,_Ty &&,ATL::CStringT<wchar_t,StrTraitMFC<wchar_t,ATL::ChTraitsCRT<wchar_t>>> &&)' being compiled
	1>          with
	1>[
		1>              _Rx = bool,
			1>              _Callable = _Decayed,
			1>              _Ty = int
			1>]

AnswerRe: C++ lambda callbacks, how to initialize with NULL pointer ? Pin
Richard Andrew x6414-Sep-15 11:36
professionalRichard Andrew x6414-Sep-15 11:36 
GeneralRe: C++ lambda callbacks, how to initialize with NULL pointer ? Pin
Member 853403514-Sep-15 21:42
Member 853403514-Sep-15 21:42 
Questiondata structure and algoritm Pin
Member 1197512010-Sep-15 10:26
Member 1197512010-Sep-15 10:26 
AnswerRe: data structure and algoritm Pin
Afzaal Ahmad Zeeshan10-Sep-15 10:41
professionalAfzaal Ahmad Zeeshan10-Sep-15 10:41 
GeneralRe: data structure and algoritm Pin
Member 1197512010-Sep-15 10:55
Member 1197512010-Sep-15 10:55 
QuestionRe: data structure and algoritm Pin
CPallini10-Sep-15 21:19
mveCPallini10-Sep-15 21:19 
AnswerRe: data structure and algoritm Pin
David Crow11-Sep-15 2:11
David Crow11-Sep-15 2:11 
QuestionRe: data structure and algoritm Pin
CPallini11-Sep-15 2:35
mveCPallini11-Sep-15 2:35 
AnswerRe: data structure and algoritm Pin
jschell11-Sep-15 11:08
jschell11-Sep-15 11:08 
AnswerRe: data structure and algoritm Pin
David Crow11-Sep-15 2:10
David Crow11-Sep-15 2:10 
AnswerRe: data structure and algoritm Pin
jschell11-Sep-15 11:12
jschell11-Sep-15 11:12 
Questionfreestanding Pin
Member 1194028910-Sep-15 6:16
Member 1194028910-Sep-15 6:16 
QuestionRe: freestanding Pin
Richard MacCutchan10-Sep-15 7:04
mveRichard MacCutchan10-Sep-15 7:04 
AnswerRe: freestanding Pin
Member 1194028910-Sep-15 16:05
Member 1194028910-Sep-15 16:05 
GeneralRe: freestanding Pin
Richard MacCutchan10-Sep-15 21:41
mveRichard MacCutchan10-Sep-15 21:41 
AnswerRe: freestanding Pin
David Crow11-Sep-15 2:15
David Crow11-Sep-15 2:15 
GeneralRe: freestanding Pin
Member 1194028911-Sep-15 11:57
Member 1194028911-Sep-15 11:57 

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.