Does std::istringstream::imbue own the object passed

Viewed 473

I'm using Boost to convert a date of the form "01-Jan-2000" to a julian number. The way I do this is to use

int toJulian(std::string date)
{
    std::locale loc = std::locale(std::locale::classic(), new boost::posix_time::time_input_facet("%d-%b-%Y"));
    std::istringstream ss(date);
    ss.imbue(loc);
    boost::posix_time::ptime p;
    ss >> p;
    return p.date().julian_day();
}

(This is along the lines of the examples in the Boost documentation).

But it's not clear to me if this leaks memory or not. I don't have an explicit delete. Obviously if imbue passes ownership of the pointer in loc to the stream then perhaps it's deleted when ss goes out of scope.

Am I correct?

See http://www.boost.org/doc/libs/1_43_0/doc/html/date_time/date_time_io.html#date_time.format_flags

1 Answers
Related