Re: New compose and format API



On Sun, 2007-08-26 at 19:23 +0200, Ole Laursen wrote:
> Daniel Elstner <daniel kitta googlemail com> writes:
> 
> > Done.  The API now looks like this:
> >
> >   s = ustring::compose("%1 is lower than %2.",
> >                        12, ustring::format(std::hex, 16));
> 
> I just want to add that I think it's cool. One problem with my library
> is that you actually quite often need a itoa like function. I played
> for a while with a design for a more complete iostream-like
> replacement that would split out the object-to-string conversion from
> the interfacing-with-files-or-other-stuff part but never got far.

Ole, the Ardour project has been using your "library" for a long time
(though we chose to call "compose" "string_compose" to avoid endless
namespace classes with ustring/boost etc). we recently added the crusty
old C++ "to_string()" cf:

template <class T> std::string 
to_string (T t, std::ios_base & (*f)(std::ios_base&))
{
	std::ostringstream oss;
	oss << f << t;
	return oss.str();
}

other than its potential inefficiences, what are the defects with this?





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]