From 5881882ed7dd5f79526a79ea0a511fa67596ef6d 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 | 5765 +++++++++++++++++---------------- src/json.hpp.re2c | 4447 +++++++++++++------------ test/src/unit-class_lexer.cpp | 48 +- test/src/unit-udt.cpp | 641 ++-- 4 files changed, 5700 insertions(+), 5201 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 75ed1ca5bd..ea5d1a0a8e 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -117,12 +117,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 /*! @@ -133,7 +133,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. @@ -151,14 +154,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. @@ -169,17 +172,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) @@ -189,122 +192,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; - - static constexpr auto value = - std::is_constructible::value and - CompatibleLimits::is_integer and - RealLimits::is_signed == CompatibleLimits::is_signed; + 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; }; 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 @@ -312,17 +315,17 @@ template