17 #ifndef FLATBUFFERS_STL_EMULATION_H_ 18 #define FLATBUFFERS_STL_EMULATION_H_ 23 #include <type_traits> 28 #if defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) 29 #define FLATBUFFERS_CPP98_STL 30 #endif // defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) 32 #if defined(FLATBUFFERS_CPP98_STL) 34 #endif // defined(FLATBUFFERS_CPP98_STL) 40 #if (defined(_MSC_VER) && _MSC_VER > 1700 ) \ 41 || (defined(__cpp_alias_templates) && __cpp_alias_templates >= 200704) \ 42 || (defined(__cplusplus) && __cplusplus >= 201103L) 43 #define FLATBUFFERS_TEMPLATES_ALIASES 52 return value[value.length() - 1];
56 return value[value.length() - 1];
61 template <
typename T>
inline T *
vector_data(std::vector<T> &vector) {
64 return vector.empty() ?
nullptr : &vector[0];
68 const std::vector<T> &vector) {
69 return vector.empty() ?
nullptr : &vector[0];
72 template <
typename T,
typename V>
74 #if defined(FLATBUFFERS_CPP98_STL) 75 vector->push_back(
data);
77 vector->emplace_back(std::forward<V>(
data));
78 #endif // defined(FLATBUFFERS_CPP98_STL) 81 #ifndef FLATBUFFERS_CPP98_STL 82 #if defined(FLATBUFFERS_TEMPLATES_ALIASES) 87 public std::numeric_limits<T> {};
88 #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) 91 public std::numeric_limits<T> {
95 return std::numeric_limits<T>::min();
100 public std::numeric_limits<float> {
102 static float lowest() {
return -FLT_MAX; }
106 public std::numeric_limits<double> {
108 static double lowest() {
return -DBL_MAX; }
113 static unsigned long long min() {
return 0ULL; }
114 static unsigned long long max() {
return ~0ULL; }
115 static unsigned long long lowest() {
122 static long long min() {
123 return static_cast<long long>(1ULL << ((
sizeof(
long long) << 3) - 1));
125 static long long max() {
126 return static_cast<long long>(
127 (1ULL << ((
sizeof(
long long) << 3) - 1)) - 1);
129 static long long lowest() {
133 #endif // FLATBUFFERS_CPP98_STL 135 #if defined(FLATBUFFERS_TEMPLATES_ALIASES) 136 #ifndef FLATBUFFERS_CPP98_STL 137 template <
typename T>
using is_scalar = std::is_scalar<T>;
138 template <
typename T,
typename U>
using is_same = std::is_same<T,U>;
140 template <
typename T>
using is_unsigned = std::is_unsigned<T>;
141 template <
typename T>
using make_unsigned = std::make_unsigned<T>;
144 template <
typename T>
using is_scalar = std::tr1::is_scalar<T>;
145 template <
typename T,
typename U>
using is_same = std::tr1::is_same<T,U>;
147 std::tr1::is_floating_point<T>;
148 template <
typename T>
using is_unsigned = std::tr1::is_unsigned<T>;
154 template<>
struct make_unsigned<char> {
using type =
unsigned char; };
155 template<>
struct make_unsigned<short> {
using type =
unsigned short; };
156 template<>
struct make_unsigned<int> {
using type =
unsigned int; };
157 template<>
struct make_unsigned<long> {
using type =
unsigned long; };
159 struct make_unsigned<long long> {
using type =
unsigned long long; };
160 #endif // !FLATBUFFERS_CPP98_STL 163 template <
typename T>
struct is_scalar :
public std::is_scalar<T> {};
164 template <
typename T,
typename U>
struct is_same :
public std::is_same<T,U> {};
166 public std::is_floating_point<T> {};
167 template <
typename T>
struct is_unsigned :
public std::is_unsigned<T> {};
168 template <
typename T>
struct make_unsigned :
public std::make_unsigned<T> {};
169 #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) 171 #ifndef FLATBUFFERS_CPP98_STL 172 #if defined(FLATBUFFERS_TEMPLATES_ALIASES) 173 template <
class T>
using unique_ptr = std::unique_ptr<T>;
180 template <
class T>
class unique_ptr :
public std::unique_ptr<T> {
187 std::unique_ptr<T>::reset(u.release());
191 std::unique_ptr<T>::reset(u.release());
195 return std::unique_ptr<T>::operator=(p);
198 #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) 205 typedef T element_type;
211 reset(const_cast<unique_ptr*>(&u)->release());
213 ~unique_ptr() { reset(); }
215 unique_ptr& operator=(
const unique_ptr& u) {
216 reset(const_cast<unique_ptr*>(&u)->release());
220 unique_ptr& operator=(unique_ptr&& u) {
225 unique_ptr& operator=(T* p) {
230 const T& operator*()
const {
return *ptr_; }
231 T* operator->()
const {
return ptr_; }
232 T*
get()
const noexcept {
return ptr_; }
233 explicit operator bool()
const {
return ptr_ !=
nullptr; }
242 void reset(T* p =
nullptr) {
245 if (value)
delete value;
248 void swap(unique_ptr& u) {
260 return x.get() == y.get();
263 template <
class T,
class D>
bool operator==(
const unique_ptr<T>& x,
265 return static_cast<D*
>(x.get()) == y;
268 template <
class T>
bool operator==(
const unique_ptr<T>& x, intptr_t y) {
269 return reinterpret_cast<intptr_t
>(x.get()) == y;
271 #endif // !FLATBUFFERS_CPP98_STL 275 #endif // FLATBUFFERS_STL_EMULATION_H_ unique_ptr(unique_ptr &&u)
unique_ptr(std::unique_ptr< T > &&u)
unique_ptr & operator=(unique_ptr &&u)
unique_ptr & operator=(T *p)
void swap(linb::any &lhs, linb::any &rhs) noexcept
T * vector_data(std::vector< T > &vector)
const T * data(const std::vector< T, Alloc > &v)
void vector_emplace_back(std::vector< T > *vector, V &&data)
unique_ptr & operator=(std::unique_ptr< T > &&u)
char & string_back(std::string &value)