Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Static library with MFC support SOLVED Pin
Vaclav_17-Aug-13 3:11
Vaclav_17-Aug-13 3:11 
QuestionA template question Pin
EQ Learner13-Aug-13 9:50
EQ Learner13-Aug-13 9:50 
AnswerRe: A template question Pin
pasztorpisti13-Aug-13 12:22
pasztorpisti13-Aug-13 12:22 
GeneralRe: A template question Pin
EQ Learner14-Aug-13 4:08
EQ Learner14-Aug-13 4:08 
GeneralRe: A template question Pin
pasztorpisti14-Aug-13 5:21
pasztorpisti14-Aug-13 5:21 
GeneralRe: A template question Pin
EQ Learner14-Aug-13 5:55
EQ Learner14-Aug-13 5:55 
GeneralRe: A template question Pin
pasztorpisti14-Aug-13 6:03
pasztorpisti14-Aug-13 6:03 
GeneralRe: A template question Pin
EQ Learner14-Aug-13 6:13
EQ Learner14-Aug-13 6:13 
Ok, to be more specific, I have redefined the otherclass to enable it has an << operator:
C++
class otherclass
{
public:
	otherclass(void):i(0)	{}

	friend std::ostream & operator << (std::ostream & os, otherclass &Obj)
	{
		os << Obj.i;
		return (os);
	}

	int i;
};


In the Serialize_SFINAE name space, I modified it to handle the otherclass serialization:
C++
namespace Serialize_SFINAE
{
    template <typename T>
    auto Serialize(T& obj, std::ostream &os) -> decltype(obj.Serialize(os),void())
    {
        obj.Serialize(os);
    }
 
    // fallback method
    template <typename T>
    void Serialize( T& obj, std::ostream &os, ...)
    {
        // replace this with valid code if you want to handle this error at runtime instead of compile time
//        obj.this_class_doesnt_have_a_serialize_method;

		os << obj;
    }
}


So now the program can handle the otherclassserialization. However, when switch back to myclass, compiler generate an ambiguous call message: error C2668: 'Serialize_SFINAE::Serialize' : ambiguous call to overloaded function

So what should the second Serialize(..) within that name space be in order to handle the object without Serialize internally implemented?
GeneralRe: A template question Pin
pasztorpisti14-Aug-13 8:29
pasztorpisti14-Aug-13 8:29 
GeneralRe: A template question Pin
EQ Learner14-Aug-13 8:57
EQ Learner14-Aug-13 8:57 
GeneralRe: A template question Pin
pasztorpisti14-Aug-13 9:29
pasztorpisti14-Aug-13 9:29 
Questionhow can i improve my c programming in different ways Pin
Member 985748713-Aug-13 2:18
Member 985748713-Aug-13 2:18 
AnswerRe: how can i improve my c programming in different ways Pin
NotPolitcallyCorrect13-Aug-13 2:29
NotPolitcallyCorrect13-Aug-13 2:29 
AnswerRe: how can i improve my c programming in different ways Pin
CPallini13-Aug-13 2:32
mveCPallini13-Aug-13 2:32 
JokeRe: how can i improve my c programming in different ways Pin
pasztorpisti13-Aug-13 3:29
pasztorpisti13-Aug-13 3:29 
AnswerRe: how can i improve my c programming in different ways Pin
pasztorpisti13-Aug-13 3:15
pasztorpisti13-Aug-13 3:15 
GeneralRe: how can i improve my c programming in different ways Pin
Erudite_Eric13-Aug-13 4:33
Erudite_Eric13-Aug-13 4:33 
GeneralRe: how can i improve my c programming in different ways Pin
CPallini13-Aug-13 9:17
mveCPallini13-Aug-13 9:17 
GeneralRe: how can i improve my c programming in different ways Pin
pasztorpisti13-Aug-13 9:22
pasztorpisti13-Aug-13 9:22 
AnswerRe: how can i improve my c programming in different ways Pin
Erudite_Eric13-Aug-13 4:35
Erudite_Eric13-Aug-13 4:35 
GeneralRe: how can i improve my c programming in different ways Pin
CPallini13-Aug-13 9:18
mveCPallini13-Aug-13 9:18 
AnswerRe: how can i improve my c programming in different ways Pin
jschell13-Aug-13 8:46
jschell13-Aug-13 8:46 
Questionc++ with QT exe file error Pin
Mkhitar_Sargsyan12-Aug-13 21:08
Mkhitar_Sargsyan12-Aug-13 21:08 
GeneralRe: c++ with QT exe file error Pin
Richard MacCutchan12-Aug-13 22:05
mveRichard MacCutchan12-Aug-13 22:05 
GeneralRe: c++ with QT exe file error Pin
SoMad12-Aug-13 22:43
professionalSoMad12-Aug-13 22:43 

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.