VC6 problem: locale loc(locale::classic(), new myfac)
-
Yes I am still supporting VC6 in this project and it has to be cross platform. Buried in the VC6 MSDN Library under “
locale::facet
” is the line “locale loc(locale::classic(), new myfac);
”. Which is correct for latter versions of the MS STL, but there is nolocale
constructor that takes alocale
and afacet
defined in the VC6 STL version of locale. My unsatisfactory workaround is:#ifdef _ADDFAC // Dinkumware macro
std::locale myLoc = std::_ADDFAC(std::locale::classic(), new my_codecvt);
#else
std::locale myLoc = std::locale(std::locale::classic(), new my_codecvt);
#endifDo you have a better one?
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
Yes I am still supporting VC6 in this project and it has to be cross platform. Buried in the VC6 MSDN Library under “
locale::facet
” is the line “locale loc(locale::classic(), new myfac);
”. Which is correct for latter versions of the MS STL, but there is nolocale
constructor that takes alocale
and afacet
defined in the VC6 STL version of locale. My unsatisfactory workaround is:#ifdef _ADDFAC // Dinkumware macro
std::locale myLoc = std::_ADDFAC(std::locale::classic(), new my_codecvt);
#else
std::locale myLoc = std::locale(std::locale::classic(), new my_codecvt);
#endifDo you have a better one?
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
I'm sure this is teaching grandma to suck eggs, but the only thing I'd suggest is to encapsulate that in another function, so you only need to do it once, i.e:
template<class Facet>
std::locale AddFacet(std::locale const& l, const Facet* f)
{
#ifdef _ADDFAC // Dinkumware macro
return std::_ADDFAC(std::locale::classic(), new my_codecvt);
#else
return std::locale(std::locale::classic(), new my_codecvt);
#endif
}Alternatively, use this:
#ifndef _ADDFAC // Dinkumware macro
#define _ADDFAC (std::locale)
#endifand use _ADDFAC for all platforms.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p