15 #ifndef RAPIDJSON_INTERNAL_META_H_
16 #define RAPIDJSON_INTERNAL_META_H_
18 #include "../rapidjson.h"
22 RAPIDJSON_DIAG_OFF(effc++)
25 #if defined(_MSC_VER) && !defined(__clang__)
27 RAPIDJSON_DIAG_OFF(6334)
30 #if RAPIDJSON_HAS_CXX11_TYPETRAITS
31 #include <type_traits>
51 static const bool Value = Cond;
52 typedef BoolType
Type;
54 typedef BoolType<true> TrueType;
55 typedef BoolType<false> FalseType;
64 template <
typename T1,
typename T2>
71 struct SelectIfImpl<false>
73 template <
typename T1,
typename T2>
79 template <
bool C,
typename T1,
typename T2>
80 struct SelectIfCond : SelectIfImpl<C>::template Apply<T1, T2>
83 template <
typename C,
typename T1,
typename T2>
84 struct SelectIf : SelectIfCond<C::Value, T1, T2>
88 template <
bool Cond1,
bool Cond2>
89 struct AndExprCond : FalseType
93 struct AndExprCond<true, true> : TrueType
96 template <
bool Cond1,
bool Cond2>
97 struct OrExprCond : TrueType
101 struct OrExprCond<false, false> : FalseType
105 template <
typename C>
106 struct BoolExpr : SelectIf<C, TrueType, FalseType>
::Type
109 template <
typename C>
110 struct NotExpr : SelectIf<C, FalseType, TrueType>
::Type
113 template <
typename C1,
typename C2>
114 struct AndExpr : AndExprCond<C1::Value, C2::Value>
::Type
117 template <
typename C1,
typename C2>
118 struct OrExpr : OrExprCond<C1::Value, C2::Value>
::Type
124 template <
typename T>
127 typedef const T
Type;
129 template <
bool Constify,
typename T>
130 struct MaybeAddConst : SelectIfCond<Constify, const T, T>
133 template <
typename T>
138 template <
typename T>
139 struct RemoveConst<const T>
147 template <
typename T,
typename U>
148 struct IsSame : FalseType
151 template <
typename T>
152 struct IsSame<T, T> : TrueType
156 template <
typename T>
157 struct IsConst : FalseType
160 template <
typename T>
161 struct IsConst<const T> : TrueType
165 template <
typename CT,
typename T>
166 struct IsMoreConst : AndExpr<IsSame<typename RemoveConst<CT>::Type, typename RemoveConst<T>::Type>,
167 BoolType<IsConst<CT>::Value >= IsConst<T>::Value>>
::Type
171 template <
typename T>
172 struct IsPointer : FalseType
175 template <
typename T>
176 struct IsPointer<T*> : TrueType
183 #if RAPIDJSON_HAS_CXX11_TYPETRAITS
185 template <
typename B,
typename D>
186 struct IsBaseOf : BoolType<::std::is_base_of<B, D>::value>
192 template <
typename B,
typename D>
198 typedef char (&Yes)[1];
199 typedef char (&No)[2];
201 template <
typename T>
202 static Yes Check(
const D*, T);
203 static No Check(
const B*,
int);
207 operator const B*()
const;
213 Value = (
sizeof(Check(Host(), 0)) ==
sizeof(Yes))
217 template <
typename B,
typename D>
218 struct IsBaseOf : OrExpr<IsSame<B, D>, BoolExpr<IsBaseOfImpl<B, D>>>
::Type
227 template <
bool Condition,
typename T =
void>
232 template <
typename T>
233 struct EnableIfCond<false, T>
237 template <
bool Condition,
typename T =
void>
242 template <
typename T>
243 struct DisableIfCond<true, T>
247 template <
typename Condition,
typename T =
void>
248 struct EnableIf : EnableIfCond<Condition::Value, T>
252 template <
typename Condition,
typename T =
void>
253 struct DisableIf : DisableIfCond<Condition::Value, T>
261 template <
typename T>
262 struct RemoveSfinaeTag;
263 template <
typename T>
264 struct RemoveSfinaeTag<SfinaeTag& (*)(T)>
269 #define RAPIDJSON_REMOVEFPTR_(type) \
270 typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag< \
271 ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*)type>::Type
273 #define RAPIDJSON_ENABLEIF(cond) \
274 typename ::RAPIDJSON_NAMESPACE::internal::EnableIf<RAPIDJSON_REMOVEFPTR_(cond)>::Type* = NULL
276 #define RAPIDJSON_DISABLEIF(cond) \
277 typename ::RAPIDJSON_NAMESPACE::internal::DisableIf<RAPIDJSON_REMOVEFPTR_(cond)>::Type* = NULL
279 #define RAPIDJSON_ENABLEIF_RETURN(cond, returntype) \
280 typename ::RAPIDJSON_NAMESPACE::internal::EnableIf<RAPIDJSON_REMOVEFPTR_(cond), \
281 RAPIDJSON_REMOVEFPTR_(returntype)>::Type
283 #define RAPIDJSON_DISABLEIF_RETURN(cond, returntype) \
284 typename ::RAPIDJSON_NAMESPACE::internal::DisableIf<RAPIDJSON_REMOVEFPTR_(cond), \
285 RAPIDJSON_REMOVEFPTR_(returntype)>::Type
291 #if defined(_MSC_VER) && !defined(__clang__)
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:822
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
Definition: allocators.h:459
Type
Type of JSON value.
Definition: rapidjson.h:760
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition: rapidjson.h:500