Example error for boost::numeric_cast

Hello! The example for boost::numeric_cast contains documentation, which clearly is wrong and stumbles the reader. On http://boost.org/libs/numeric/conversion/doc/numeric_cast.html#numeric_cast we have the lines unsigned long l=std::numeric_limits<unsigned long>::max(); // This works, because unsigned integral types cannot cause overflow. unsigned char c=numeric_cast<unsigned char>(l); which contradict the behaviour and the range checking logic presented on http://boost.org/libs/numeric/conversion/doc/converter.html#rchklogic Btw.: Further on the #include directive, namely #include <boost/numeric_cast.hpp> should be corrected to #include <boost/numeric/conversion/cast.hpp> Greetings from Bremen, Daniel Krügler

Daniel Krügler wrote:
Hello!
The example for boost::numeric_cast contains documentation, which clearly is wrong and stumbles the reader.
On
http://boost.org/libs/numeric/conversion/doc/numeric_cast.html#numeric_cast
we have the lines
unsigned long l=std::numeric_limits<unsigned long>::max(); // This works, because unsigned integral types cannot cause overflow. unsigned char c=numeric_cast<unsigned char>(l);
which contradict the behaviour and the range checking logic presented on
http://boost.org/libs/numeric/conversion/doc/converter.html#rchklogic
Btw.: Further on the #include directive, namely
#include <boost/numeric_cast.hpp>
should be corrected to
#include <boost/numeric/conversion/cast.hpp>
Greetings from Bremen,
Daniel Krügler
You're absolutely right! Thank you for the report. Best -- Fernando Cacciola SciSoft http://fcacciola.50webs.com/

Fernando Cacciola wrote:
You're absolutely right! Thank you for the report.
No problem at all! In the same line I would like to add that a colleague of point pointed out this morning that on http://boost.org/libs/numeric/conversion/doc/converter.html#examples the typedef is written as typedef boost::numeric::converter<int,doublegt; Double2Int ; and should be adapted for .html page to look like typedef boost::numeric::converter<int,double> Double2Int ; Greetings from Bremen, Daniel
participants (2)
-
Daniel Krügler
-
Fernando Cacciola