From be1d3de49be7cf8453171b9c0bc5149a6404c68d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 18 Dec 2016 20:32:09 +0100 Subject: [PATCH] :lipstick: moved changes to re2c file and ran `make pretty` --- src/json.hpp | 6315 +++++++++++++++++---------------- src/json.hpp.re2c | 4716 +++++++++++++----------- test/src/unit-class_lexer.cpp | 48 +- test/src/unit-udt.cpp | 623 ++-- 4 files changed, 6100 insertions(+), 5602 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index f883d9ed..7325e7c8 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -126,12 +126,12 @@ using conditional_t = typename std::conditional::type; template using is_scoped_enum = std::integral_constant::value and - std::is_enum::value>; + std::is_enum::value>; template using is_unscoped_enum = std::integral_constant::value and - std::is_enum::value>; + std::is_enum::value>; // TODO update this doc /*! @@ -142,7 +142,10 @@ 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) -template struct make_void { using type = void; }; +template struct make_void +{ + using type = void; +}; template using void_t = typename make_void::type; // Implementation of 3 C++17 constructs: conjunction, disjunction, negation. @@ -160,14 +163,14 @@ template struct conjunction : std::true_type {}; template struct conjunction : B1 {}; template struct conjunction - : conditional_t, B1> {}; +: conditional_t, B1> {}; -template struct negation : std::integral_constant {}; +template struct negation : std::integral_constant < bool, !B::value > {}; template struct disjunction : std::false_type {}; template struct disjunction : B1 {}; template struct disjunction - : conditional_t> {}; +: conditional_t> {}; /*! @brief Helper to determine whether there's a key_type for T. @@ -178,17 +181,17 @@ contains a `mapped_type`, whereas `std::vector` fails the test. @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; \ - }; + 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) @@ -198,122 +201,122 @@ NLOHMANN_JSON_HAS_HELPER(iterator) #undef NLOHMANN_JSON_HAS_HELPER template -struct is_compatible_object_type_impl : std::false_type{}; +struct is_compatible_object_type_impl : std::false_type {}; template struct is_compatible_object_type_impl { - static constexpr auto value = - std::is_constructible::value and - std::is_constructible::value; + static constexpr auto value = + std::is_constructible::value and + std::is_constructible::value; }; template struct is_compatible_object_type { - // 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, - has_key_type>::value, - RealType, CompatibleObjectType>::value; + // 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, + has_key_type>::value, + RealType, CompatibleObjectType >::value; }; template -struct is_compatible_array_type_impl : std::false_type{}; +struct is_compatible_array_type_impl : std::false_type {}; template struct is_compatible_array_type_impl { - static constexpr auto value = - not std::is_same::value and - not std::is_same::value and - not std::is_same::value and - not std::is_same::value and - not std::is_same::value and - not std::is_same::value; + static constexpr auto value = + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value; }; 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 - static auto constexpr value = is_compatible_array_type_impl< - conjunction>, - has_value_type, - has_iterator>::value, - BasicJson, CompatibleArrayType>::value; + // 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>, + has_value_type, + has_iterator>::value, + BasicJson, CompatibleArrayType >::value; }; template -struct is_compatible_integer_type_impl : std::false_type{}; +struct is_compatible_integer_type_impl : std::false_type {}; template struct is_compatible_integer_type_impl { - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; + using RealLimits = std::numeric_limits; + using CompatibleLimits = std::numeric_limits; - static constexpr auto value = - std::is_constructible::value and - CompatibleLimits::is_integer and - RealLimits::is_signed == CompatibleLimits::is_signed; + static constexpr auto value = + std::is_constructible::value and + CompatibleLimits::is_integer and + RealLimits::is_signed == CompatibleLimits::is_signed; }; template struct is_compatible_integer_type { - static constexpr auto value = is_compatible_integer_type_impl< - std::is_arithmetic::value, RealIntegerType, - CompatibleNumberIntegerType>::value; + static constexpr auto value = is_compatible_integer_type_impl < + std::is_arithmetic::value, RealIntegerType, + CompatibleNumberIntegerType >::value; }; template struct is_compatible_float_type { - static constexpr auto value = - std::is_constructible::value and - std::is_floating_point::value; + static constexpr auto value = + std::is_constructible::value and + std::is_floating_point::value; }; template struct is_compatible_basic_json_type { - static auto constexpr value = - is_unscoped_enum::value or - std::is_same::value or - std::is_constructible::value or - std::is_same::value or - 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; + static auto constexpr value = + is_unscoped_enum::value or + std::is_same::value or + std::is_constructible::value or + std::is_same::value or + 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; }; template struct is_basic_json_nested_class { - static auto constexpr value = std::is_same::value or - std::is_same::value or - std::is_same::value or - std::is_same::value or - std::is_same::value or - std::is_same::value; + static auto constexpr value = std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value; }; // This trait checks if JSONSerializer::from_json(json const&, udt&) exists @@ -321,17 +324,17 @@ template