Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DEBUG_NEW Pin
iceman861620-Jan-10 13:55
iceman861620-Jan-10 13:55 
QuestionProgram Which: Takes numbers from a user, and sum's them. Pin
rbwest8619-Jan-10 13:44
rbwest8619-Jan-10 13:44 
AnswerRe: Program Which: Takes numbers from a user, and sum's them. Pin
loyal ginger19-Jan-10 14:53
loyal ginger19-Jan-10 14:53 
GeneralRe: Program Which: Takes numbers from a user, and sum's them. Pin
rbwest8619-Jan-10 15:46
rbwest8619-Jan-10 15:46 
GeneralRe: Program Which: Takes numbers from a user, and sum's them. Pin
loyal ginger20-Jan-10 15:18
loyal ginger20-Jan-10 15:18 
AnswerRe: Program Which: Takes numbers from a user, and sum's them. Pin
rbwest8619-Jan-10 16:40
rbwest8619-Jan-10 16:40 
GeneralRe: Program Which: Takes numbers from a user, and sum's them. Pin
Wes Aday19-Jan-10 17:05
professionalWes Aday19-Jan-10 17:05 
AnswerFunction pointer + template = INTERNAL COMPILER ERROR [answered] Pin
Code-o-mat19-Jan-10 6:35
Code-o-mat19-Jan-10 6:35 
Hello people!

Here's a simplified version of what i am trying to do (sorry for the long code):
class CTestClass
{
public:
  void AMethod(int x);
  BOOL BMethod(char y);
};

template<typename TParamType>
class TTestTemplate
{
  typedef void(CTestClass::* LPFN_AMETHOD)(TParamType);
  typedef BOOL(CTestClass::* LPFN_BMETHOD)(TParamType);

  bool fIsAFn;
  union {
    LPFN_AMETHOD fnA;
    LPFN_BMETHOD fnB;
  };
public:
  TTestTemplate(LPFN_AMETHOD pFn):fnA(pFn), fIsAFn(true ) {}
  TTestTemplate(LPFN_BMETHOD pFn):fnB(pFn), fIsAFn(false) {}

  void Call(CTestClass *pInstance, TParamType val);
};

template<typename TParamType>
void TTestTemplate<TParamType>::Call(CTestClass *pInstance, TParamType val)
{
  if (fIsAFn) (pInstance::*fnA)(val); //<---- !!!!!!!!!!!!!! THIS IS THE LINE !!!!!!!!!!!!!! -------------
  else (pInstance::*fnB)(val);
}

At the highlighted line i am getting an INTERNAL COMPILER ERROR, i googled around and this seems to be a bug in the compiler (am not absolutely sure though), so my question is: does anyone maybe know of any workaround for this? I am using VC++ 2003 (using a newer version of VC++ is sadly not an option since this is out of my hand, i am stuck with it). If i could somehow get it to work it would simplify my life a lot...

[ANSWER] Ok, seems to be that i am trying to call the methods thorough the pointers wrong, if i use this:
(pInstance->*fnA)(val); instead of the :: version it compiles and runs fine. So i guess the bug is that it does not give any usefull error not that it can't "eat" function pointers and templates together. What are the odds...[/ANSWER]

> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <

modified on Tuesday, January 19, 2010 12:56 PM

GeneralRe: Function pointer + template = INTERNAL COMPILER ERROR [answered] Pin
CODEPC19-Jan-10 7:49
CODEPC19-Jan-10 7:49 
GeneralRe: Function pointer + template = INTERNAL COMPILER ERROR [answered] Pin
Code-o-mat19-Jan-10 8:03
Code-o-mat19-Jan-10 8:03 
QuestionProgramming MS Visual C++, David J. Kruglinski - missing files needed Pin
andwan019-Jan-10 5:27
andwan019-Jan-10 5:27 
QuestionInternetOpenUrl with proxy Pin
YaronNir19-Jan-10 4:31
YaronNir19-Jan-10 4:31 
AnswerRe: InternetOpenUrl with proxy Pin
YaronNir19-Jan-10 20:22
YaronNir19-Jan-10 20:22 
QuestionwaveOutWrite Problem Pin
Aric Wang19-Jan-10 3:59
Aric Wang19-Jan-10 3:59 
AnswerRe: waveOutWrite Problem Pin
Covean19-Jan-10 4:08
Covean19-Jan-10 4:08 
GeneralRe: waveOutWrite Problem Pin
Aric Wang19-Jan-10 4:27
Aric Wang19-Jan-10 4:27 
GeneralRe: waveOutWrite Problem Pin
Aric Wang20-Jan-10 17:44
Aric Wang20-Jan-10 17:44 
GeneralRe: waveOutWrite Problem Pin
Covean20-Jan-10 22:54
Covean20-Jan-10 22:54 
AnswerRe: waveOutWrite Problem Pin
molesworth19-Jan-10 5:00
molesworth19-Jan-10 5:00 
GeneralRe: waveOutWrite Problem Pin
Aric Wang19-Jan-10 16:22
Aric Wang19-Jan-10 16:22 
Question21 days socket programming Pin
darshic19-Jan-10 2:53
darshic19-Jan-10 2:53 
AnswerRe: 21 days socket programming Pin
CPallini19-Jan-10 3:05
mveCPallini19-Jan-10 3:05 
GeneralRe: 21 days socket programming Pin
darshic19-Jan-10 3:14
darshic19-Jan-10 3:14 
GeneralRe: 21 days socket programming Pin
CPallini19-Jan-10 3:20
mveCPallini19-Jan-10 3:20 
GeneralRe: 21 days socket programming Pin
darshic19-Jan-10 3:34
darshic19-Jan-10 3:34 

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.