From b1c1eb8095834bcf32810388b7900933e79f2bad Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 27 Mar 2013 16:49:11 +0100 Subject: [PATCH] doc: other fixes in the example * doc/numeric_cast.qbk: Shorten wording. Add missing end-of-line in output. 'f' must be available, don't leave it in too short a scope. --- doc/numeric_cast.qbk | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/numeric_cast.qbk b/doc/numeric_cast.qbk index a6a7ec5..7940573 100644 --- a/doc/numeric_cast.qbk +++ b/doc/numeric_cast.qbk @@ -111,21 +111,20 @@ The following example performs some typical conversions between numeric types: short s=numeric_cast(i); // This conversion succeeds (is in range) } catch(negative_overflow& e) { - std::cout << e.what(); + std::cout << e.what() << std::endl; } catch(positive_overflow& e) { - std::cout << e.what(); + std::cout << e.what() << std::endl; } + float f=-42.1234; try { - float f=-42.1234; - - // This will cause a boost::numeric::negative_overflow exception to be thrown + // This will throw a boost::numeric::negative_overflow exception. unsigned int i=numeric_cast(f); } catch(bad_numeric_cast& e) { - std::cout << e.what(); + std::cout << e.what() << std::endl; } double d= f + numeric_cast(123); // int -> double @@ -134,14 +133,14 @@ The following example performs some typical conversions between numeric types: try { - // This will cause a boost::numeric::positive_overflow exception to be thrown + // This will throw a boost::numeric::positive_overflow exception. // 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(l); } catch(positive_overflow& e) { - std::cout << e.what(); + std::cout << e.what() << std::endl; } -- 1.8.2