Skip to content

Conversation

hugary1995
Copy link
Contributor

Using std::optional to avoid breaking API.
This is needed in moose element subdomain modifier where we need to project a function onto a subset of the mesh.

@hugary1995 hugary1995 marked this pull request as draft October 2, 2025 21:42
@hugary1995
Copy link
Contributor Author

I will add some tests later. @roystgnr please let me know if this looks okay to you before I go too far.

@roystgnr
Copy link
Member

roystgnr commented Oct 8, 2025

Sorry I missed the comment here!

Definitely we want to add this feature.

I'd have made the range argument a pointer with a nullptr default, but out of force of habit rather than because it's a good idea, and I'm happy with std::optional here. Someone correct me if I'm wrong, but best practices now is to use std::optional for any object that's lightweight enough to not worry about copying, right? (and probably also for heavyweight objects, eventually, when C++26 adds optional<T&> support?) Our ranges are currently like 48 bytes, so the copies should be fine.

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