mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
try fixing issue #482
This commit is contained in:
14
util.h
14
util.h
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user