Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-05-07 07:14:27


Hi Everyone,

I've recently tried the following (inlined test) which isolates the
problem I've encountered with boost::lexical_cast<int8_t>:

#include <iostream>
#include <boost/lexical_cast.hpp>

int main(int argc, char * argv[]) {
    int8_t value;
    try {
        value = boost::lexical_cast<int8_t>("127");
    } catch (std::exception & e) {
        std::cerr << e.what() << '\n';
    }
    return 0;
};

This is compiled with gcc 4.1.2 on Linux. Any idea why 127 wouldn't
fit into an 8-bit signed integer? The defined range for signed 8 bit
integers should be -127..+127 right?

Am I missing something?

Insights and pointers would be most appreciated.

-- 
Dean Michael C. Berris
http://cplusplus-soup.blogspot.com/
mikhailberis AT gmail DOT com
+63 928 7291459

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