Boost logo

Boost :

Subject: Re: [boost] [lexical_cast] Strange behaviour
From: raindog_at_[hidden]
Date: 2009-03-18 12:12:31


What exactly do you think -1 is as an unsigned int?
------Original Message------
From: Robert Jones
Sender: boost-bounces_at_[hidden]
To: boost_at_[hidden]
ReplyTo: boost_at_[hidden]
Sent: Mar 18, 2009 9:03 AM
Subject: [boost] [lexical_cast] Strange behaviour

Trying again 'cos I mucked up the code last time!

This code

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

int main()
{
  using namespace std;

  try
  {
    unsigned int u=boost::lexical_cast<unsigned int>("-1");
    cout << u << '\n';
  }
  catch(const std::exception&)
  {
    cout << "Exception" << '\n';
  }
}

produces

4294967295

on MSVC7 & 8

rather than an exception. Is it supposed to do this?

Rob.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Sent from my Verizon Wireless BlackBerry


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