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

fix: put all operators in vector_utils.h inside namespace #57

Merged
merged 1 commit into from
Oct 21, 2023

Conversation

wdconinc
Copy link
Contributor

Briefly, what does this PR introduce?

This puts all operators inside the namespace edm4eic instead of having part of them in, part of them out. Having some out of the namespace affects other headers included after edm4eic/vector_utils.h, e.g.

In file included from /home/wdconinc/git/EICrecon/src/algorithms/tracking/TrackProjector.cc:30:
/opt/._local/kabrpic7bxoos4p6tucb5wr2sce6oeio/include/edm4eic/vector_utils.h:153:34: error: overloaded 'operator/' must have at least one parameter of class or enumeration type
  153 | template <edm4eic::VectorND V> V operator/(const V& v, const double d) {
      |                                  ^
/opt/._local/kabrpic7bxoos4p6tucb5wr2sce6oeio/include/fmt/core.h:1483:29: note: in instantiation of function template specialization 'operator/<int>' requested here
 1483 | enum { max_packed_args = 62 / packed_arg_bits };
      |                             ^

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue #__)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No. I guess you could be relying on these operators being available outside of the edm4eic namespace... but that's off-label use of this product.

@wdconinc wdconinc requested review from sly2j and veprbl October 18, 2023 00:16
Copy link
Member

@veprbl veprbl left a comment

Choose a reason for hiding this comment

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

@wdconinc
Copy link
Contributor Author

Yeah, it has another level with utils, but all is in edm4hep at least.

@veprbl
Copy link
Member

veprbl commented Oct 20, 2023

I don't quite understand the error. It seems like this needs just the explicit keyword in front of each operator definition instead.

If I understand correctly, users may need to put using edm4eic::operator/ after this.

@veprbl
Copy link
Member

veprbl commented Oct 21, 2023

I see, the VectorND here is a C++ concept. And this only shows up with clang: https://godbolt.org/z/YGa8bW9b8
The explicit keyword doesn't apply since this is not a class. Surprisingly, this works

template <VectorND V, std::floating_point P> V operator/(const V& v, const P d) {
    return v;
}

@veprbl veprbl merged commit aecf04f into main Oct 21, 2023
3 checks passed
@veprbl veprbl deleted the wdconinc-patch-1 branch October 21, 2023 07:13
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.

2 participants