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 compilation errors with C++20 #2940

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Fix compilation errors with C++20 #2940

wants to merge 1 commit into from

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

core/algo/threaded_loop.h Show resolved Hide resolved
core/algo/threaded_loop.h Show resolved Hide resolved
core/algo/threaded_loop.h Show resolved Hide resolved
@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).
@daljit46 daljit46 marked this pull request as ready for review July 3, 2024 13:16
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.

1 participant