I'm seeing a problem with lexical_cast. The following code when
--- In Boost-Users@y..., "Jason Fischl"
convert from string to string fails when passed an empty string. The library code that is doing this lexical_cast does not and can not know that the input and output types are the same.
I believe that this code should not throw.
#include <iostream> #include
main() { std::string input(""); try { boost::lexical_caststd::string(input); } catch (boost::bad_lexical_cast& e) { std::cout << "Failed" << std::endl; } }
Since one can't partially specialise function templates, one way to
do it could be that the library included something like this:
namespace boost
{
template<>
std::string lexical_caststd::string,std::string(std::string arg)
{
return arg;
}
template<>
std::string lexical_cast