-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress Clang-Tidy warning #4311
base: develop
Are you sure you want to change the base?
Conversation
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @nlohmann |
: json_base_class_t(std::forward<json_base_class_t>(other)), | ||
m_data(std::move(other.m_data)) | ||
// check that passed value is valid (has to be done before forwarding) | ||
: json_base_class_t((other.assert_invariant(false), std::forward<json_base_class_t>(other))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just do assert_invariant(false);
in the body (assert it in this
after moving instead of asserting in other
) to avoid this mess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possibility for avoiding all these issues is to do std::swap()
on m_data
and other.m_data
in the body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not at all happy with this. I also thought about swapping...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for asking a question for something that is probably obvious, but which constructor of json_base_class_t
is this call valid for? I suppose it is one of the basic_json
constructors being used here?
FWIW, it should be completely fine to check the invariants after the initializer list has been evaluated. Is there a possibility to consider rewriting the data
move constructor so these assignments don't need to be done at this level?
I am currently blocked here: template < typename BasicJsonType, typename T, std::size_t... Idx >
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
{
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
} gives
Any ideas? |
Every other Alternatively, if there is a defined need for moving from the |
I made some progress and now have an interesting issue: template<class KeyType, detail::enable_if_t<
detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
reference at(KeyType && key)
{
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
if (it == m_data.m_value.object->end())
{
JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this)); // <-- warning here: 'key' used after it was forwarded
}
return set_parent(it->second);
} To fix this, I could either make a copy of |
If If I suppose that if you'd like to keep this to be a universal reference the exception message should perhaps not contain |
I would say don't mention |
We already have two versions for const references and rvalues. Unfortunately, it seems to depend on the compiler and C++ standard which version is used, so I am currently struggling to adjust the test cases (with and without key in the exception). |
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @nlohmann |
I opened #4489 to get the CI green. Most issues from this PR are not addressed, but at least we have a clean slate. It would be great if someone could have a look. |
# .github/workflows/macos.yml # include/nlohmann/detail/input/parser.hpp # include/nlohmann/detail/meta/std_fs.hpp # include/nlohmann/json.hpp # single_include/nlohmann/json.hpp
modernize-use-designated-initializers does not work with C++11