Overte C++ Documentation
AndroidHacks.h
1 //
2 // androidhacks.h
3 // interface/src
4 //
5 // Created by Cristian Duarte & Gabriel Calero on 1/4/17.
6 // Copyright 2017 High Fidelity, Inc.
7 //
8 // hacks to get android to compile
9 //
10 // Distributed under the Apache License, Version 2.0.
11 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12 //
13 
14 
15 #pragma once
16 #ifndef hifi_shared_platform_androidhacks_h
17 #define hifi_shared_platform_androidhacks_h
18 
19 #include <string>
20 #include <sstream>
21 
22 #include <ciso646>
23 
24 // Only for gnu stl, so checking if using llvm
25 // (If there is a better check than this http://stackoverflow.com/questions/31657499/how-to-detect-stdlib-libc-in-the-preprocessor, improve this one)
26 #if (_LIBCPP_VERSION)
27  // NOTHING, these functions are well defined on libc++
28 #else
29 
30 using namespace std;
31 namespace std
32 {
33  // to_string impl
34  // error: no member named 'to_string' in namespace 'std'
35  // http://stackoverflow.com/questions/26095886/error-to-string-is-not-a-member-of-std
36  template <typename T>
37  inline std::string to_string(T value) {
38  std::ostringstream os;
39  os << value;
40  return os.str();
41  }
42 
43  inline float stof(std::string str) {
44  return atof(str.c_str());
45  }
46 }
47 
48 #endif // _LIBCPP_VERSION
49 
50 #endif // hifi_androidhacks_h