Re: Why this template code fails to comple?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



try this:
class Imy
{
public:
   enum ReCode_et {
       E_Success = 0,
       E_Fail = -1,
   };
};

template<class T>
bool CheckSuccess(typename T::ReCode_et err)
{
if(err==T::E_Success)
       return true;
   else
       return false;
}

int main()
{
   return !CheckSuccess<Imy>(Imy::E_Success);
}

----- Original Message ----- From: ""Chen (陈) Jun (军)"" <chjfth@xxxxxxxxx>
To: <gcc-help@xxxxxxxxxxx>
Sent: Monday, December 15, 2008 4:00 AM
Subject: Why this template code fails to comple?


Please help me check the small C++ snippet.

class Imy
{
public:
   enum ReCode_et {
       E_Success = 0,
       E_Fail = -1,
   };
};

template<class T>
bool CheckSuccess(typename T::ReCode_et err)
{
   if(err==T::E_Success)
       return true;
   else
       return false;
}

int main()
{
   return !CheckSuccess(Imy::E_Success);
}

When compiling with gcc 4.1.0, it fails with


tpl1.cpp: In function ‘int main()’:
tpl1.cpp:21: error: no matching function for call to ‘CheckSuccess(Imy::ReCode_et)’


But I think the CheckSuccess can decude that T is Imy , right?



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux