Boost logo

Boost :

From: Gregory Dai (gregory.dai_at_[hidden])
Date: 2006-08-31 22:38:53


On 8/21/06, Emil Dotchevski <emildotchevski_at_[hidden]> wrote:
>
> Hello,
>
> I just finished an update to the exception library I am planning to
> propose
> for addition to Boost. I appreciate all feedback, including
> incompatibility
> reports with various compilers (I believe the implementation to be
> standard-conforming, but I have only tested with msvc 7.1/8.0 and gcc
> 3.4.4).
>
> As usual, the latest documentation is here:
>
> http://www.revergestudios.com/boost-exception/boost-exception.htm
>
> Here is a zip file with the source code, complete with jamfiles and tests:
>
> http://www.revergestudios.com/boost-exception/boost-exception.zip
>
> Here's what's new in this update: class boost::exception now defines
> what()
> function, similarly to std::exception. It automatically formats a message
> which combines all exception info stored by operator<< in the
> boost::exception object. The message is not user-friendly; it is designed
> for dumping in log files and for other debugging systems.
>
> For what() to work, the system needs to be able to convert the exception
> info values stored in a boost::exception to string. Because this is not a
> critical feature, I thought it wouldn't be a good idea to require the user
> code to provide such a conversion for everything. The current
> implementation
> generates a string representation of each exception info value (at the
> time
> exception_info is called) as follows:
>
> - If a suitable overload for the unqualified call to to_string (passing
> the
> exception info value as the only argument) is found, that overload is
> used.
>
> - Otherwise, if a suitable overload for serializing the exception info
> value
> into a std::ostringstream is found, that overload is used.
>
> - Otherwise the system gives up and uses a generic "stub" string to
> indicate
> that the exception info value could not be converted to string.
>
> This is accomplished through the to_string function template, which has
> the
> following signature:
>
> template <class T>
> std::string to_string( T const &, char const * stub );
>
> Do you think that to_string is universally useful? Is there anything in
> Boost with similar functionality? Perhaps we can make to_string a separate
> addition to Boost?

std::string s = boost::lexical_cast<std::string>(T const&);

Thanks,
> Emil
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
Thanks,
Greg

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk