Skip to content

Conversation

@daljit46
Copy link
Member

@daljit46 daljit46 commented Jul 3, 2024

PerThread and Shared classes in threaded_loop.h now longer use references as data members, but instead they use pointers. This fixes some errors when compiling with C++20 as the minimum standard (due to errors in initialising the variables in the constructors) and also allows us to avoid following the rule of 5 (e.g. no need to define custom copy/move constructors and assignment operators).
More generally, I think we should try to avoid using references as data members of classes because they limit the implementation of a class and also slightly hurt readability (for example, it's not obvious when accessing the member that it is a reference).

@daljit46 daljit46 requested a review from jdtournier July 3, 2024 12:18
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@daljit46 daljit46 self-assigned this Jul 3, 2024
@daljit46 daljit46 marked this pull request as draft July 3, 2024 12:46
PerThread and Shared in threaded_loop.h now longer use references as
data members. This fixes some errors when compiling with C++20 as the
minimum standard (due to errors in initialising the variables in the
constructors) and also allows us to avoid following the rule of 5 (e.g.
no need to define custom copy/move constructors and assignment
operators).
@Lestropie
Copy link
Member

If it is desirable to support multiple language standards in this way, it might be worth investing in expanding the CI actions to test such compilation. We've previously avoided doing this across major versions of compilers to save trees, but maybe with compiler caching it's now more reasonable, and certainly the list of language standards would be shorter.

(We've also not yet done it for Python minor versions---might have caught the 3.12 deprecations earlier---but that would be better addressed in a separate PR as a follow-up to #2865)

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.

3 participants