diff --git a/include/rapidjson/internal/meta.h b/include/rapidjson/internal/meta.h new file mode 100644 index 0000000..8a1e966 --- /dev/null +++ b/include/rapidjson/internal/meta.h @@ -0,0 +1,71 @@ +#ifndef RAPIDJSON_INTERNAL_META_H_ +#define RAPIDJSON_INTERNAL_META_H_ + +//@cond RAPIDJSON_INTERNAL +namespace rapidjson { +namespace internal { + +template struct IntegralC { enum { Value = N }; }; +template struct BoolType : IntegralC {}; +struct TrueType : BoolType {}; +struct FalseType : BoolType {}; + +template struct AddConst { typedef const T Type; }; +template struct RemoveConst { typedef T Type; }; +template struct RemoveConst { typedef T Type; }; + +template struct SelectIfCond; +template struct SelectIfCond { typedef T1 Type; }; +template struct SelectIfCond { typedef T2 Type; }; + +template +struct SelectIf : SelectIfCond {}; + +template +struct MaybeAddConst : SelectIfCond {}; + +template struct IsSame { enum { Value = false }; }; +template struct IsSame { enum { Value = true }; }; + +template struct IsConst { enum { Value = false }; }; +template struct IsConst { enum { Value = true }; }; + +template +struct IsMoreConst { + enum { Value = + ( IsSame< typename RemoveConst::Type, typename RemoveConst::Type>::Value + && ( IsConst::Value >= IsConst::Value ) ) + }; +}; + +template struct EnableIfCond; +template struct EnableIfCond { typedef T Type; }; +template struct EnableIfCond { /* empty */ }; + +template +struct DisableIfCond : EnableIfCond {}; + +template +struct EnableIf : EnableIfCond {}; + +template +struct DisableIf : DisableIfCond {}; + +// SFINAE helpers +struct SfinaeResultTag {}; +template struct RemoveSfinaeFptr {}; +template struct RemoveSfinaeFptr { typedef T Type; }; + +#define RAPIDJSON_REMOVEFPTR_(type) \ + typename ::rapidjson::internal::RemoveSfinaeFptr \ + < ::rapidjson::internal::SfinaeResultTag&(*) type>::Type + +#define RAPIDJSON_ENABLEIF(cond) \ + typename ::rapidjson::internal::EnableIf \ + ::Type * = NULL + +} // namespace internal +} // namespace rapidjson +//@endcond + +#endif // RAPIDJSON_INTERNAL_META_H_