From: "Electric Monk"
"Terje Slettebø"
wrote in message news:031b01c2fc98$f1065db0$8d6c6f50@pc... However, one can still simply overload/specialise the lexical_cast
function
template, to get the same effect, even though this is not documented. It's similar to being able to specialise components in the standard library. I think this is a simpler way of doing it than the earlier way.
For example:
#include
namespace boost { template<> double lexical_cast<double>(const std::string &source) { // ... } }
This barfs under my compiler (BCB4/Win32), since you can't specialize a function template.
The compiler is right, but for a different reason. I hadn't tested the above
code, and the reason it doesn't work is that the primary template looks like
this:
template
From what little investigation I've done so far, it seems that the best place to do this specialization is in the boost::detail::lexical_stream class, such as the specialization already done for extracting a std::string from the lexical_stream.
You could do it there, but in this case you'd have to specialise the whole class, with all the member functions. Regards, Terje