Boost logo

Boost Users :

From: Eduardo Chao (efchao_at_[hidden])
Date: 2003-02-21 23:37:53


Hello,

I am a new suscriber to the list.
I want to report what I consider a bug in lexical_cast conversion template.
First, I wanted to use it to convert things to std::string (Target).
It throws a bad_lexical_cast_exception when I pass an empty std::string object (one
that is default-constructed or constructed with "") as the Source argument.
It throws it because the condition (interpreter >> result ) evaluates to
false.

My solution was to specialize the function template this way:

template<> lexical_cast<std::string>(const std::string &str)
{
    return str;
}

but it is not so general to support const std::string or const std::string&
as Target type or perhaps std::string or const std::string etc as Source.
Correct me if I am wrong, so I learn from you more experienced Boost (and then C++) users.

That's all for now.

Thanks in advance.

Eduardo Chao.

[Non-text portions of this message have been removed]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net