Update of /cvsroot/boost/boost/libs/numeric/conversion/doc
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16836/libs/numeric/conversion/doc
Modified Files:
Tag: RC_1_34_0
conversion_traits.html converter.html numeric_cast.html
Log Message:
none_t/none reimplemented to avoid precompiled header issues (thanks to Joe
Gottam)
optional<T> now has direct relational operator
optional<T>::operator-> fixed for reference types
Index: conversion_traits.html
===================================================================
RCS file:
/cvsroot/boost/boost/libs/numeric/conversion/doc/conversion_traits.html,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -u -d -r1.6 -r1.6.4.1
--- conversion_traits.html 4 Jun 2005 06:01:14 -0000 1.6
+++ conversion_traits.html 1 Mar 2007 23:08:33 -0000 1.6.4.1
@@ -297,9 +297,12 @@
<H2><A NAME="examples">Examples</A></H2>
<BLOCKQUOTE>
- <PRE>#include <boost/numeric/conversion_traits.hpp>
+ <PRE>#include <cassert>
+#include <typeinfo>
+#include <boost/numeric/conversion/conversion_traits.hpp>
-int main() {
+int main()
+{
// A trivial conversion.
typedef boost::numeric::conversion_traits<short,short>
Short2Short_Traits ;
@@ -307,24 +310,24 @@
// A subranged conversion.
typedef boost::numeric::conversion_traits<double,unsigned int>
UInt2Double_Traits ;
- assert ( UInt2Double_Traits::mixture::value ==
boost::numeric::integral_to_float ) ;
+ assert ( UInt2Double_Traits::int_float_mixture::value ==
boost::numeric::integral_to_float ) ;
assert ( UInt2Double_Traits::sign_mixture::value ==
boost::numeric::unsigned_to_signed ) ;
assert ( !UInt2Double_Traits::subranged::value ) ;
assert ( typeid(UInt2Double_Traits::supertype) == typeid(double) ) ;
assert ( typeid(UInt2Double_Traits::subtype) == typeid(unsigned int) ) ;
// A doubly subranged conversion.
- assert ( boost::numeric::conversion_traits<short, unsigned
short>::subranged::value
- && boost::numeric::conversion_traits<unsigned short,
short>::subranged::value
- )
+ assert ( (boost::numeric::conversion_traits<short, unsigned
short>::subranged::value) );
+ assert ( (boost::numeric::conversion_traits<unsigned short,
short>::subranged::value) );
return 0;
-}</PRE>
+}
+</PRE>
</BLOCKQUOTE>
<HR>
<P>Back to <A HREF="index.html">Numeric Conversion library index</A></P>
<HR>
-<P>Revised 16 May 2005</P>
+<P>Revised 23 November 2006</P>
<p>© Copyright Fernando Luis Cacciola Carballal, 2004</p>
<p> Use, modification, and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file <a
href="../../../../LICENSE_1_0.txt">
Index: converter.html
===================================================================
RCS file: /cvsroot/boost/boost/libs/numeric/conversion/doc/converter.html,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -d -r1.7 -r1.7.2.1
--- converter.html 12 Aug 2005 13:02:35 -0000 1.7
+++ converter.html 1 Mar 2007 23:08:33 -0000 1.7.2.1
@@ -241,11 +241,12 @@
<HR>
<H2><A NAME="examples">Examples</A></H2>
<BLOCKQUOTE>
- <PRE>#include <boost/numeric/conversion/converter.hpp>
+ <PRE> #include <cassert>
+ #include <boost/numeric/conversion/converter.hpp>
-int main() {
+ int main() {
- typedef boost::numeric::converter<int,doublegt; Double2Int ;
+ typedef boost::numeric::converter<int,double> Double2Int ;
int x = Double2Int::convert(2.0);
assert ( x == 2 );
Index: numeric_cast.html
===================================================================
RCS file: /cvsroot/boost/boost/libs/numeric/conversion/doc/numeric_cast.html,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- numeric_cast.html 12 Aug 2005 13:02:35 -0000 1.4
+++ numeric_cast.html 1 Mar 2007 23:08:33 -0000 1.4.2.1
@@ -52,10 +52,10 @@
<H2><A NAME="numeric_cast"><CODE>numeric_cast</CODE></A></H2>
<BLOCKQUOTE>
<PRE>template<typename Target, typename Source> inline
-typename boost::numeric::converter<Traget,Source>::result_type
+typename boost::numeric::converter<Target,Source>::result_type
numeric_cast ( Source arg )
{
- return boost::numeric::converter<Traget,Source>::convert(arg);
+ return boost::numeric::converter<Target,Source>::convert(arg);
}
</PRE> </BLOCKQUOTE>
<P>numeric_cast returns the result of converting a value of type
Source to a value of type
@@ -67,18 +67,21 @@
<P>The following example performs some typical conversions between
numeric
types: </P>
<BLOCKQUOTE>
- <PRE>#include <boost/numeric_cast.hpp>
+ <PRE>#include <boost/numeric/conversion/cast.hpp>
#include <iostream>
int main()
{
using boost::numeric_cast;
- using boost::bad_numeric_cast;
- using boost::positive_overflow;
- using boost::negative_overflow;
- try {
+
+ using boost::numeric::bad_numeric_cast;
+ using boost::numeric::positive_overflow;
+ using boost::numeric::negative_overflow;
+
+ try
+ {
int i=42;
- short s=numeric_cast<short>(i);
+ short s=numeric_cast<short>(i); // This conversion succeeds (is in
range)
}
catch(negative_overflow& e) {
std::cout << e.what();
@@ -87,32 +90,40 @@
std::cout << e.what();
}
- try {
+ try
+ {
float f=-42.1234;
- // This will cause a boost::negative_underflow exception to be thrown
+
+ // This will cause a boost::numeric::negative_overflow exception to be
thrown
unsigned int i=numeric_cast<unsigned int>(f);
+ }
+ catch(bad_numeric_cast& e) {
+ std::cout << e.what();
+ }
- double d=f+numeric_cast<double>(i);
-
- 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);
-
- unsigned short us=std::numeric_limits<unsigned short>::max();
- // This will cause an positive_overflow exception to be thrown
- short s=numeric_cast<short>(us);
+ double d= f + numeric_cast<double>(123); // int -> double
+ unsigned long l=std::numeric_limits<unsigned long>::max();
+
+ try
+ {
+ // This will cause a boost::numeric::positive_overflow exception to be
thrown
+ // NOTE: *operations* on unsigned integral types cannot cause overflow
+ // but *conversions* to a signed type ARE range checked by numeric_cast.
+
+ unsigned char c=numeric_cast<unsigned char>(l);
}
- catch(bad_numeric_cast& e) {
+ catch(positive_overflow& e) {
std::cout << e.what();
}
+
return 0;
}</PRE> </BLOCKQUOTE> <BR> <BR> <HR>
<HR>
<P>Back to <A HREF="index.html">Numeric Conversion library index</A></P>
<HR>
-<P>Revised 23 June 2004</P>
+<P>Revised 20 May 2006</P>
<p>© Copyright Boost 1999</p>
<p>© Copyright Fernando Luis Cacciola Carballal, 1999,2004</p>
<p> Use, modification, and distribution are subject to the Boost Software
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs