Re: [boost] [lexical_cast] A suggestion

7 Feb
2009
7 Feb
'09
1:17 p.m.
some bashing snipped...
Why not compromise? 1. Make the lexical_cast changes for optional that Andrew Troschinetz suggested. 2. Add the following convert_to.hpp file: #include <boost/lexical_cast.hpp> #include <boost/optional.hpp> namespace boost { template <typename Target, typename Source> inline Target convert_to(const Source& arg) { return lexical_cast< optional<Target> >(arg).get_value_or(Target()); } template <typename Target, typename Source> inline Target convert_to(const Source& arg, const Target& fallback) { return lexical_cast< optional<Target> >(arg).get_value_or(fallback); } } 3. Use convert_to instead of lexical_cast. 4. Everyone happy? Regards, Anders Dalvander
5968
Age (days ago)
5968
Last active (days ago)
0 comments
1 participants
participants (1)
-
Anders Dalvander