Ticket #8343: 0002-doc-other-fixes-in-the-example.patch

File 0002-doc-other-fixes-in-the-example.patch, 2.2 KB (added by Akim Demaille <akim.demaille@…>, 10 years ago)
  • doc/numeric_cast.qbk

    From b1c1eb8095834bcf32810388b7900933e79f2bad Mon Sep 17 00:00:00 2001
    From: Akim Demaille <akim@lrde.epita.fr>
    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 b The following example performs some typical conversions between numeric types:  
    111111            short s=numeric_cast<short>(i); // This conversion succeeds (is in range)
    112112        }
    113113        catch(negative_overflow& e) {
    114             std::cout << e.what();
     114            std::cout << e.what() << std::endl;
    115115        }
    116116        catch(positive_overflow& e) {
    117             std::cout << e.what();
     117            std::cout << e.what() << std::endl;
    118118        }
    119119
     120        float f=-42.1234;
    120121        try
    121122        {
    122             float f=-42.1234;
    123 
    124             // This will cause a boost::numeric::negative_overflow exception to be thrown
     123            // This will throw a boost::numeric::negative_overflow exception.
    125124            unsigned int i=numeric_cast<unsigned int>(f);
    126125        }
    127126        catch(bad_numeric_cast& e) {
    128             std::cout << e.what();
     127            std::cout << e.what() << std::endl;
    129128        }
    130129
    131130        double d= f + numeric_cast<double>(123); // int -> double
    The following example performs some typical conversions between numeric types:  
    134133
    135134        try
    136135        {
    137             // This will cause a boost::numeric::positive_overflow exception to be thrown
     136            // This will throw a boost::numeric::positive_overflow exception.
    138137            // NOTE: *operations* on unsigned integral types cannot cause overflow
    139138            // but *conversions* to a signed type ARE range checked by numeric_cast.
    140139
    141140            unsigned char c=numeric_cast<unsigned char>(l);
    142141        }
    143142        catch(positive_overflow& e) {
    144             std::cout << e.what();
     143            std::cout << e.what() << std::endl;
    145144        }
    146145
    147146