Skip to content
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

MINIFICPP-2159 Add heterogeneous lookup to FlatMap #1612

Closed
wants to merge 4 commits into from

Conversation

martinzink
Copy link
Member

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.

@martinzink martinzink marked this pull request as ready for review July 21, 2023 08:21
extensions/libarchive/CompressContent.cpp Outdated Show resolved Hide resolved
libminifi/include/utils/FlatMap.h Show resolved Hide resolved
libminifi/include/utils/FlatMap.h Show resolved Hide resolved
Comment on lines 297 to 293
template<typename T>
requires std::equality_comparable_with<K, T>
bool contains(const T& key) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template<typename T>
requires std::equality_comparable_with<K, T>
bool contains(const T& key) const {
bool contains(std::equality_comparable_with<K> auto const& key) const {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, changed it and the others (except for operator[]) in f209288

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like MSVC doesnt like constraint auto, Im getting

C:\nifi-minifi-cpp\libminifi\test\unit\FlatMapTests.cpp(51): fatal error C1001: Internal compiler error.
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\trees.c', line 24533)
 To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com/

I've found some reported issues with constraint auto and MSVC but those issues should be solved, ours is a bit more complex. I will try to create an MRE about this issue and file a bug with microsoft, in the meantime should I revert to explicit templates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the shortest for that's working with all targeted compilers.
That translates to first fallback to this:

  template<std::equality_comparable_with<K> T>
  bool contains(T const& key) const {

and second fallback to the original version.

On an unrelated note, we should add noexcept wherever it makes sense. It may make our life easier down the line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, the first fallback works on MSVC aswell. 617fc38
Adding noexcept where applicable is a good idea, I didnt find any obvious target on a quick glance, and I didnt want to burden this PR with a more complex analysis. Should I file a new jira for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For noexcept, I was thinking operator[], find, erase and contains. It may need to be conditional, e.g. erase does swap, so it needs to be std::is_nothrow_swappable_v. I was hoping for noexcept find, but it would have to rely on a complex condition, so it may not be feasible after all.

If nothing obvious stands out, don't bother with the new Jira.

@szaszm szaszm closed this in cafc3b1 Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants