From 748250e6efc156fce6f916666813b4e89ace8791 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 18 Dec 2016 21:02:09 +0100 Subject: [PATCH] :lipstick: some cleanup --- src/json.hpp | 56 +++++++++++++++++++++-------------------------- src/json.hpp.re2c | 56 +++++++++++++++++++++-------------------------- 2 files changed, 50 insertions(+), 62 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index ea5d1a0a8e..efa721b752 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -132,7 +132,8 @@ using is_unscoped_enum = namespace detail { -// Very useful construct against boilerplate (more boilerplate needed than in C++17: http://en.cppreference.com/w/cpp/types/void_t) +// very useful construct against boilerplate (more boilerplate needed than in +// C++17: http://en.cppreference.com/w/cpp/types/void_t) template struct make_void { using type = void; @@ -165,29 +166,29 @@ 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 + +This 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 */ -#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; \ +#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; \ }; -NLOHMANN_JSON_HAS_HELPER(mapped_type) -NLOHMANN_JSON_HAS_HELPER(key_type) -NLOHMANN_JSON_HAS_HELPER(value_type) -NLOHMANN_JSON_HAS_HELPER(iterator) +NLOHMANN_JSON_HAS_HELPER(mapped_type); +NLOHMANN_JSON_HAS_HELPER(key_type); +NLOHMANN_JSON_HAS_HELPER(value_type); +NLOHMANN_JSON_HAS_HELPER(iterator); #undef NLOHMANN_JSON_HAS_HELPER @@ -207,8 +208,8 @@ struct is_compatible_object_type_impl template struct is_compatible_object_type { - // As noted ahead, we need to stop evaluating traits if CompatibleObjectType = void - // hence the conjunction + // As noted ahead, we need to stop evaluating traits if + // `CompatibleObjectType = void`, hence the conjunction static auto constexpr value = is_compatible_object_type_impl < conjunction>, has_mapped_type, @@ -240,8 +241,8 @@ struct is_compatible_array_type_impl template struct is_compatible_array_type { - // the check for CompatibleArrayType = void is done in is_compatible_object_type - // but we need the conjunction here as well + // the check for CompatibleArrayType = void is done in + // `is_compatible_object_type`, but we need the conjunction here as well static auto constexpr value = is_compatible_array_type_impl < conjunction>, @@ -293,8 +294,7 @@ struct is_compatible_basic_json_type is_compatible_array_type::value or is_compatible_object_type::value or is_compatible_float_type::value or - is_compatible_integer_type::value or + is_compatible_integer_type::value or is_compatible_integer_type::value; }; @@ -311,8 +311,7 @@ struct is_basic_json_nested_class }; // This trait checks if JSONSerializer::from_json(json const&, udt&) exists -template