Fix #3497: Add support for compiling in g++ 4.4 and 4.5

- Removed uses of lambda expressions

- Added custom defines for constexpr and nullptr

- Removed trailing comma of last value from generated enums
This commit is contained in:
Chandra Penke
2016-01-06 08:31:53 -08:00
committed by Nalinichandra Penke
parent 01025fa22b
commit b63ebad49d
12 changed files with 166 additions and 90 deletions

View File

@@ -38,6 +38,8 @@
#include <limits.h>
#endif
#include "flatbuffers/flatbuffers.h"
namespace flatbuffers {
// Convert an integer or floating point value to a string.
@@ -68,7 +70,7 @@ template<> inline std::string NumToString<double>(double t) {
auto p = s.find_last_not_of('0');
if (p != std::string::npos) {
s.resize(p + 1); // Strip trailing zeroes.
if (s.back() == '.')
if (s[s.size() - 1] == '.')
s.erase(s.size() - 1, 1); // Strip '.' if a whole number.
}
return s;
@@ -197,8 +199,8 @@ inline std::string StripFileName(const std::string &filepath) {
inline std::string ConCatPathFileName(const std::string &path,
const std::string &filename) {
std::string filepath = path;
if (path.length() && path.back() != kPathSeparator &&
path.back() != kPosixPathSeparator)
if (path.length() && path[path.size() - 1] != kPathSeparator &&
path[path.size() - 1] != kPosixPathSeparator)
filepath += kPathSeparator;
filepath += filename;
return filepath;