Modify

Opened 16 years ago

Closed 12 years ago

#18 closed Bugs (Fixed)

lexical_cast fails in some cases

Reported by: nobody Owned by: kevlin
Milestone: Component: lexical_cast
Version: None Severity:
Keywords: Cc:

Description

The following code causes a bad_lexical_cast exception

std::string x=boost::lexical_cast<std::string>("");

Is this how lexical_cast should perform?

An empty standard string also causes an exception

std::string x=boost::lexical_cast<std::string>(std::string());

I understand that the underlying stringstream causes this behavior but it does not seem to be intuitive. Calls like the ones above can occur when using member templates like the following

class A
{
public:
  template<typename T>
  std::string f(const T& value)
  {
    return boost::lexical_cast<std::string>(value);
  }
}

Solutions to this problem are welcome.

Attachments (0)

Change History (1)

comment:1 Changed 12 years ago by kevlin

Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain kevlin.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.