#include <sstream>
#include <exception>
template<typename Dest, typename Source> Dest convert(const Source &s)
{
std::stringstream ss;
ss << s;
Dest ret;
if( !(ss >> ret) ) throw std::exception("Failed to convert!");
return ret;
}
int i = converter<int>("4");
std::string s = converter<std::string>(3453);
unsigned int x = converter<unsigned int>(s);
#include <sstream>
#include <exception>
template<typename Dest, typename Source> Dest convert(const Source &s)
{
std::stringstream ss;
ss << s;
Dest ret;
if( !(ss >> ret) ) throw std::exception("Failed to convert!");
return ret;
}
int i = converter<int>("4");
std::string s = converter<std::string>(3453);
unsigned int x = converter<unsigned int>(s);
if( !(ss >> ret) ) throw std::exception("Failed to convert!");
if( !(ss >> ret) ) throw std::exception("Failed to convert!");
Usage: