
From: jeffrey.hellrung@gmail.com
On Tue, Feb 14, 2012 at 4:18 AM, Olaf van der Spek <ml@vdspek.org> wrote: [...]
Unlike int vs. double, a formatting object and a string are NOT conceptually the samething, so adding an implicit conversion would be bad. (Actually, we should limit implicitconversions in general; so converting weakly-connected types should definitely be out.)
Why would that be bad? The conversion from format to string is well defined and used (very) frequently. It's also cumbersome at the moment.
Compare: 1: set(dict2, "link", (boost::format("../../?q=%s") % name).str()); 2: set(dict2, "link", boost::format("../../?q=%s") % name);
I don't see a problem with 1. It makes your conversion intentions clear, and I don't find it onerous in the least.
(My opinion, of course.)
- Jeff
Upon some reflection, neither of these look natural to me. What would look natural is the following, implemented using C++11 variadic templates (and then the return value could be a string in the first place): set(dict2, "link", boost::format("../../?q=%s", name)); Regards, Nate