Opened 14 years ago
#2811 new Feature Requests
date_time iostream dependencies
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | Boost 1.39.0 | Component: | date_time |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | iostream BOOST_NO_IOSTREAM _STLP_NO_IOSTREAMS | Cc: |
Description
For footprint and performance reasons our codebase uses boost with BOOST_NO_IOSTREAM. However, date_time has some iostream dependency in the form of std::ostringstream used for formatting string outputs. For example, the method partial_date::to_string uses std::ostringstream to convert an integer to a string.
An alternative is as follows:
//! Returns string suitable for use in POSIX time zone string /*! Returns string formatted with up to 3 digits: * Jan-01 == "0" * Feb-29 == "58" * Dec-31 == "365" */ virtual std::string to_string() const { date_type d(2004, month_, day_); unsigned short c = d.day_of_year() - 1; // numbered 0-365 while day_of_year is 1 based... std::string ret; if (c/100) { ret += '0' + c/100; c = c%100; } if (c/10) { ret += '0' + c/10; c = c%10; } ret += '0' + c; return ret; }
Would you be likely to accept a patch that simply omits all the iostream-dependent API, if BOOST_NO_IOSTREAM is defined?
Is there a boost-friendly alternative to std::ostringstream?
Note:
See TracTickets
for help on using tickets.