|
Boost Users : |
From: thom_schu_at_[hidden]
Date: 2008-01-22 03:08:58
Hi,
to be compatible with a given interface I need to encapsulate a boost::gregorian::date.
I have a problem with the formatted output of the date-object.
I tried a given example:
date d(2005,Jun,25);
date_facet* facet(new date_facet("%A %B %d, %Y"));
std::stringstream ss;
ss.imbue(std::locale(std::cout.getloc(), facet));
ss << d;
std::cout << ss.str() << std::endl;
facet->format("%Y");
ss.str("");
ss << d;
std::cout << ss.str() << std::endl;
this works fine.
But the same inside an object causes an segmentation-fault:
class MyDate
{
date m_date;
std::stringstream ss;
date_facet* facet;
Date()
: m_date(day_clock::local_day()),
facet(new date_facet("%A %B %d, %Y"))
{
ss.imbue(std::locale(std::cout.getloc(), facet));
}
std::string Date::format(std::string pattern)
{
facet->format(pattern.c_str());
ss.str("");
ss << m_date;
return ss.str();
}
}
Can anybody tell me what Im doing wrong and how to do it better ?
Thanks a lot
gizmo
-- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net