Open fsandhei opened 12 months ago
The source code has not been amalgamated. @fsandhei Please read and follow the Contribution Guidelines.
The source code has not been amalgamated. @fsandhei Please read and follow the Contribution Guidelines.
Can you please try to amalgamate with an older version of astyle, like astyle 3.2? There was a breaking change in astyle which makes the output differ unfortunately.
Can you please try to amalgamate with an older version of astyle, like astyle 3.2? There was a breaking change in astyle which makes the output differ unfortunately.
Sure, I'll do it some time later today after work.
First, sorry, @nlohmann, for the trouble I'm causing here.
So, I tried amalgamating again. There seems to be some issues or inconsistencies with the astyle version 3.2.1 from the AUR versus 3.2.1-build from apt:
squeeze-line
was introduced in 3.3.x.Would you want me to perhaps unstage all the other unrelated files that got affected by this?
The source code has not been amalgamated. @fsandhei Please read and follow the Contribution Guidelines.
This is what I am using locally (patched Makefile):
# call the Artistic Style pretty printer on all source files
pretty:
/Users/niels/Downloads/astyle/build/astyle \
--style=allman \
--indent=spaces=4 \
--indent-modifiers \
--indent-switches \
--indent-preproc-block \
--indent-preproc-define \
--indent-col1-comments \
--pad-oper \
--pad-header \
--align-pointer=type \
--align-reference=type \
--add-braces \
--convert-tabs \
--close-templates \
--lineend=linux \
--preserve-date \
--suffix=none \
--formatted \
$(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp
with Astyle 3.1.
Thank you for so quick response. The amalgamation seems happy now.
Thank you for so quick response. The amalgamation seems happy now.
Thanks for your effort!
I see that the GCC 10 CI run failed. It seems to be not able to parse the concept, which is odd as it should be supported in GCC 10.
For the sake of getting this in and have the least amount of hassle I don't use concept
.
However I was pondering on the idea of having a concept
which could replace these type traits definitions for recognizing "compatible types". I tinkered with this simple concept below. It worked perfectly fine. I don't know if it is missing any details, though. Would appreciate hearing your opinion on this, as I'm far from an expert :)
#ifdef JSON_HAS_CPP_20
#include <concepts>
template <typename T, typename BasicJsonType, typename U = uncvref_t<T>>
concept CompatibleType = requires(const U& type, BasicJsonType& j) {
{ to_json(j, type) } -> std::convertible_to<void>;
};
#endif
The use of this would be quite simple, as we'd then can constrict constructors / operators with this concept:
template <CompatibleType<basic_json_t> T>
operator==(T rhs) const noexcept
{
...
}
EDIT: I realize I goofed myself. It is supported but JSON_HAS_CPP_20
is not defined because g++10
requires -std=c++2a
. I'm able to get past this by also checking for __cpp_concepts
to be defined at where we define the concept.
I'm not really sure what is Codacy is actually complaining about. The struct member is being used in the type trait. It might be a bug in Codacy. Do you have any suggestions @nlohmann?
I'm not really sure what is Codacy is actually complaining about. The struct member is being used in the type trait. It might be a bug in Codacy. Do you have any suggestions @nlohmann?
Indeed looks like a false positive. I set it to "ignore".
The source code has not been amalgamated. @fsandhei Please read and follow the Contribution Guidelines.
https://github.com/nlohmann/json/issues/4165 shows an issue with the overload resolution when attempting to compare a
std::string
withjson
from left to right. This can be fixed by changing the constraint to instead of focusing on scalar types, we constrain the comparison operator to "compatible types", in par with the catch-call constructor.Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmann
directory, runmake amalgamate
to create the single-header filessingle_include/nlohmann/json.hpp
andsingle_include/nlohmann/json_fwd.hpp
. The whole process is described here.Please don't
#ifdef
s or other means.