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

Implement remaining ranges iterator concepts and modernize array #627

Merged
merged 34 commits into from
Nov 3, 2023

Conversation

miscco
Copy link
Collaborator

@miscco miscco commented Oct 27, 2023

This implements the remaining pieces of the iterator concepts and basic ranges CPO

It cleans up the remaining <iterator> infrastructure as well as the predefined iterators reverse_iterator and move_iterator which are necessary for testing purposes later on.

Finally we also modernize <array> which is also necessary for many incoming changes as the current empty array specialization is non-conforming wrt constexpr evaluation.

Note this is currenlty based on the nonmodifying_algorithms PR as there were some merge conflicts

@miscco miscco requested review from a team as code owners October 27, 2023 08:50
@miscco miscco requested review from robertmaynard, ericniebler and gevtushenko and removed request for a team October 27, 2023 08:50
@miscco miscco force-pushed the modernize_array branch 2 times, most recently from 5d254b0 to 65e631c Compare October 27, 2023 16:32
{
template <class _T1, class _T2>
_LIBCUDACXX_NODISCARD_EXT _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool
operator()(const _T1& __lhs, const _T2& __rhs) const noexcept(noexcept(__lhs == __rhs))
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: in upstream and standard these functions do not use noexcept specifier. This can have visible side effects:

struct equal_to_1 {
  template <class _T1, class _T2>
  bool operator()(const _T1& __lhs, const _T2& __rhs) const noexcept(noexcept(__lhs == __rhs)) {
    return __lhs == __rhs;
  }
};

struct equal_to_2 {
  template <class _T1, class _T2>
  bool operator()(const _T1& __lhs, const _T2& __rhs) const {
    return __lhs == __rhs;
  }
};

int main() {
  static_assert(noexcept(equal_to_1{}(1, 2)));
  static_assert(noexcept(equal_to_2{}(1, 2)));
} 

Unless there's a strong reason to deviate from upstream, I wouldn't do that (same for __less).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Generally, adding noexcept specifiers is allowed by the standard an QoI detial.

My point is that libc++ is not good at it and we should be better, even if we do not care about exceptions on device

@miscco miscco force-pushed the modernize_array branch 8 times, most recently from 6bd91e7 to a391ed2 Compare October 29, 2023 09:17
@miscco miscco force-pushed the modernize_array branch 6 times, most recently from ca66f31 to dc40f7d Compare November 1, 2023 18:53
@miscco miscco merged commit 83b3365 into NVIDIA:main Nov 3, 2023
516 checks passed
@miscco miscco deleted the modernize_array branch November 3, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants