I'm chronically experiencing a problem while trying to deal with both unicode and ansi conditionally. Code
http://zxcvbn.googlecode.com/svn/trunk/pla...nesplaylist.cpp
You'll see, I deal with both the ANSI and Unicode cases exactly the same
But because the templates are a compile time deal, I have had to check for both at the same time. I am not aware of a polymorphic base type that would allow me to do this more generally, is there any standards compliant sort of thing? Is there a way to do run-time template specialization? This just seems outrageous and I can't see how to go about it correctly.Code:if(unicode) { wfilestream.open(filename.c_str()); fileok = !!wfilestream; } else { filestream.open(filename.c_str()); fileok = !!filestream; } if(!fileok) { std::cout << "File not opened\n"; return 0; } std::string line; std::wstring wline; bool fok; if(unicode) fok = !!std::getline(wfilestream, wline); else fok = !!std::getline(filestream, line); ... etc ...



LinkBack URL
About LinkBacks



CornedBee