0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

Apparently Android NDK doesn't support std::to_string (WTF?),

so work around it.

http://stackoverflow.com/questions/22774009/android-ndk-stdto-string-support
This commit is contained in:
James Yonan 2015-12-16 13:20:33 -07:00
parent 1e94723fcc
commit 42424a3b47
2 changed files with 13 additions and 5 deletions

View File

@ -29,10 +29,13 @@
#include <type_traits>
#include <utility>
#include <openvpn/common/platform.hpp>
namespace openvpn {
// Convert an arbitrary argument to a string.
#ifndef OPENVPN_PLATFORM_ANDROID // Android NDK apparently doesn't support std::to_string : http://stackoverflow.com/questions/22774009/android-ndk-stdto-string-support
// numeric types
template <typename T,
typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
@ -40,10 +43,14 @@ namespace openvpn {
{
return std::to_string(value);
}
#endif
// non-numeric types not specialized below
template <typename T,
typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0>
// non-numeric types
template <typename T
#ifndef OPENVPN_PLATFORM_ANDROID
, typename std::enable_if<!std::is_arithmetic<T>::value, int>::type = 0
#endif
>
inline std::string to_string(const T& value)
{
std::ostringstream os;
@ -119,7 +126,7 @@ namespace openvpn {
typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
void append(T value)
{
str_ += std::to_string(value);
str_ += openvpn::to_string(value);
}
// non-numeric types not specialized below

View File

@ -33,6 +33,7 @@
#include <openvpn/common/rc.hpp>
#include <openvpn/common/size.hpp>
#include <openvpn/common/hostport.hpp>
#include <openvpn/common/format.hpp>
#include <openvpn/tun/builder/base.hpp>
#include <openvpn/client/rgopt.hpp>
#include <openvpn/addr/ip.hpp>
@ -768,7 +769,7 @@ namespace openvpn {
int i = 0;
for (auto &e : list)
{
e.validate(title + '[' + std::to_string(i) + ']');
e.validate(title + '[' + openvpn::to_string(i) + ']');
++i;
}
}