
20 Apr
2009
20 Apr
'09
6:14 p.m.
This is not a common usecase and I see only one practical use of it.
A user might want to write a template that uses lexical_cast without having to pay the performance cost when the cast isn't necessary. Specializing lexical_cast for this case would save the user from having to specialize his own template. I'm guessing template<typename Target> Target lexical_cast(const Target& arg) { return arg; } doesn't work because the compiler can't decide between lexical_cast<Foo> and lexical_cast<Foo, Foo> for lexical_cast<Foo>(some_foo). Could something like template<typename T> T lexical_cast<T, T>(const Target& arg) work? (My syntax might not be perfect; it's been a while since I've done partial specialization.) --Jeffrey Bosboom