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

Avoid split constructor for the Range concept #1376

Open
WalterDehnen opened this issue May 3, 2024 · 2 comments
Open

Avoid split constructor for the Range concept #1376

WalterDehnen opened this issue May 3, 2024 · 2 comments

Comments

@WalterDehnen
Copy link

The current Range concept requires

Range::Range(Range &range, split);
Range::Range(Range &range, proportional_split);    // optional

This means that Range cannot be a POD type and that other constructors must be explicitly declared. Moreover, it also requires the definitions of tbb::split and tbb::proportional_split to be visible in the definition of Range (often requiring surrounding these constructors with #if and #endif directives).

Proposal: instead require

Range Range::split();
Range Range::split(std::size_t left, std::size_t right);   // optional

Granted, this requires a bit more coding on the tbb side in case of a proportional split, but the point is to make tbb more user friendly.

Such a change in the concept can be rolled out as optional, then deprecating the old version etc. All this can easily be implemented using SFINAE methods to detect the presence these methods.

@kboyarinov
Copy link
Contributor

@WalterDehnen, thank you for highlighting this interesting use case. We will consider making some changes in that regard.
We will need to discuss this in details because this change introduces potential breaks for some implementations of Range where the method split was used for something else.
May I also ask you to share more details about your use case when having Range object as POD is practically important to have better motivation for any further changes?

@WalterDehnen
Copy link
Author

WalterDehnen commented May 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants