Boost logo

Boost Users :

From: ian whittley (imw_at_[hidden])
Date: 2005-06-02 11:40:26


would it be possible to add a set of overloads to lexical_cast to allow
for more efficient conversions when the code to do so is readily
available (and especially when it is part of the standard library)?

below is part of my own rather simplistic implementation of this idea
which has been tested on VC7.1 and seems to work fine. other overloads
for floats using atof etc. proceed in a similar manner to that for ints.

   template<class T, class U>
   T to(U const& u)
     return to(u, Type2Type<T>());

   template<class T, class U>
   T to(U const& u, Type2Type<T> const&)
     return lexical_cast<T>(u);

   int to(std::string const& arg, Type2Type<int> const&)
     return atoi(arg.c_str());

ian whittley

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at