[Fwd: Re: [format] please add operator String()]

Thorsten Ottosen wrote:
... I my mind formatting is so closely tied to strings that I don't see any problem in the implicit conversion. IIRC, String.Format in other langauages return a String.
Is some valid reason for require explicit conversion? It sure would be convenient for format to convert implicitly to string. If there is a valid reason, what about a wrapper class? I've used something close to the following for the last few years, and it hasn't bit me so far : class sformat : public boost::format { public: sformat( const std::string &s ) : boost::format( s ) {} operator std::string () { return boost::str( *this ); } template <class T> sformat & operator%( T v ) { *((boost::format*)this) % v; return *this; } }; - James -- ______________________________________________ James Fowler, Open Sea Consulting 770-714-3124 / james@openseaconsulting.com 1486 Surf Court, Marietta, GA, 30066 http://www.OpenSeaConsulting.com -- ______________________________________________ James Fowler, Open Sea Consulting 770-714-3124 / james@openseaconsulting.com 1486 Surf Court, Marietta, GA, 30066 http://www.OpenSeaConsulting.com
participants (1)
-
James Fowler