try fixing issue #482

This commit is contained in:
Jeff Becker 2016-04-27 12:08:08 -04:00
parent c54f7c81c4
commit 2373b94d3e
No known key found for this signature in database
GPG key ID: AB950234D6EA286B
2 changed files with 28 additions and 11 deletions

14
util.h
View file

@ -5,11 +5,25 @@
#include <string>
#include <iostream>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
namespace i2p
{
namespace util
{
/**
wrapper arround boost::lexical_cast that "never" fails
*/
template <typename T>
T lexical_cast(const std::string & str, const T fallback) {
try {
return boost::lexical_cast<T>(str);
} catch ( ... ) {
return fallback;
}
}
namespace http
{
// in (lower case)