diff --git a/src/json.hpp b/src/json.hpp index 2265457fb..bd91a6152 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -140,6 +140,7 @@ template struct conjunction : B1 {}; template struct conjunction : conditional_t, B1> {}; + template struct negation : std::integral_constant {}; template struct disjunction : std::false_type {}; template struct disjunction : B1 {}; @@ -149,68 +150,31 @@ struct disjunction /*! @brief Helper to determine whether there's a key_type for T. - Thus helper is used to tell associative containers apart from other containers such as sequence containers. For instance, `std::map` passes the test as it contains a `mapped_type`, whereas `std::vector` fails the test. - @sa http://stackoverflow.com/a/7728728/266378 @since version 1.0.0, overworked in version 2.0.6 */ -template -struct has_mapped_type -{ - private: - template - static int detect(U&&); +#define NLOHMANN_JSON_HAS_HELPER(type) \ + template struct has_##type { \ + private: \ + template \ + static int detect(U &&); \ + \ + static void detect(...); \ + \ + public: \ + static constexpr bool value = \ + std::is_integral()))>::value; \ + }; - static void detect(...); - public: - static constexpr bool value = - std::is_integral()))>::value; -}; +NLOHMANN_JSON_HAS_HELPER(mapped_type) +NLOHMANN_JSON_HAS_HELPER(key_type) +NLOHMANN_JSON_HAS_HELPER(value_type) +NLOHMANN_JSON_HAS_HELPER(iterator) -template