2010-10-08 17:27:59 +00:00
|
|
|
/// A quick replacement for boost::lexical_cast for all the Boost haters out there
|
|
|
|
|
|
|
|
#ifndef __AI_BOOST_WORKAROUND_LEXICAL_CAST
|
|
|
|
#define __AI_BOOST_WORKAROUND_LEXICAL_CAST
|
|
|
|
|
2013-08-27 20:17:30 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2010-10-08 17:27:59 +00:00
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
|
|
|
|
/// A quick replacement for boost::lexical_cast - should work for all types a stringstream can handle
|
|
|
|
template <typename TargetType, typename SourceType>
|
|
|
|
TargetType lexical_cast( const SourceType& source)
|
|
|
|
{
|
|
|
|
std::stringstream stream;
|
|
|
|
TargetType result;
|
|
|
|
|
|
|
|
stream << source;
|
|
|
|
stream >> result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace boost
|
|
|
|
|
2011-04-22 22:23:20 +00:00
|
|
|
#endif // __AI_BOOST_WORKAROUND_LEXICAL_CAST
|
|
|
|
|